src/test/java/nl/bioinf/minorapplicationdesign/ontpillen/model/web_scraping/DrugFetcherTest.java
/**
     * Method that tests if drugFetcher correctly adds all expected drugs. The expected drug list and the actual
     * drug list are compared independent of order.
     * @throws IOException
     */
Method that tests if drugFetcher correctly adds all expected drugs. The expected drug list and the actual
drug list are compared independent of order.
Method that tests if drugFetcher correctly adds all expected drugs . The expected drug list and the actual drug list are compared independent of order .
@Test
    void parseHtml_scrapeDrugs_saveToTheDao() throws IOException {
        String[] drugNamesArray = {"alprazolam", "oxazepam", "nalmefeen", "zuclopentixol", "fenelzine", "mianserine", "antipsychotica, atypische", "nitrazepam", "amisulpride", "clobazam", "dapoxetine", "midazolam", "chloorprotixeen", "psychostimulantia", "buprenorfine/naloxon", "benzodiazepine agonisten", "dosulepine", "sertraline", "methylfenidaat", "nortriptyline", "middelen bij verslavingsziekten", "prazepam", "clorazepinezuur", "modafinil", "middelen bij alcoholverslaving", "broomperidol", "zolpidem", "melatonine", "tranylcypromine", "dexamfetamine", "risperidon", "diazepam", "coffeïne", "antipsychotica", "antipsychotica, klassieke", "brotizolam", "paliperidon", "varenicline", "venlafaxine", "fluoxetine", "antidepressiva", "periciazine", "moclobemide", "serotonineheropnameremmers, selectief", "sertindol", "amitriptyline", "imipramine", "fluvoxamine", "antidepressiva, overige", "paroxetine", "duloxetine", "cariprazine", "psycholeptica", "flunitrazepam", "brexpiprazol", "quetiapine", "pimozide", "flurazepam", "lithium", "buprenorfine (bij verslaving)", "serotonineheropnameremmers, niet-selectief", "aripiprazol", "citalopram", "clomipramine", "temazepam", "nicotine", "loprazolam", "lorazepam", "middelen bij nicotineverslaving", "psychofarmaca, overige", "fluspirileen", "lithiumzouten", "melatonine agonisten", "lormetazepam", "flupentixol", "clozapine", "buspiron", "bupropion", "MAO-remmers, niet-selectief", "methadon", "vortioxetine", "disulfiram", "atomoxetine", "lisdexamfetamine", "zopiclon", "acamprosaat", "olanzapine", "haloperidol", "bromazepam", "penfluridol", "trazodon", "pipamperon", "escitalopram", "MAO-A-remmers", "middelen bij opioïdverslaving", "slaapmiddelen", "sulpiride", "mirtazapine", "tricyclische antidepressiva", "psychostimulantia, overige", "maprotiline", "naltrexon", "agomelatine", "lurasidon", "amfetaminen", "esketamine (nasaal)", "tetracyclische antidepressiva", "carbamazepine", "chloralhydraat", "droperidol (intramusculair)", "foliumzuur", "guanfacine", "hydroxyzine", "lamotrigine", "pregabaline", "propranolol (cardiovasculair of neurologisch)", "thiamine", "valeriaan", "valproïnezuur"};
        List<String> drugNames = new ArrayList<>(Arrays.asList(drugNamesArray));
        drugNames = drugNames.stream().map(str -> str.toLowerCase()).collect(Collectors.toList());
        drugFetcher.parseHtml();
        List<String> expectedDrugs = drugDao.getAllDrugNames();
        expectedDrugs.removeAll(drugNames);
        drugNames.removeAll(drugDao.getAllDrugNames());
        assertEquals(drugNames, expectedDrugs);
    }
@ Test void parseHtml_scrapeDrugs_saveToTheDao ( ) throws IOException { String [ ] drugNamesArray = { "alprazolam" , "oxazepam" , "nalmefeen" , "zuclopentixol" , "fenelzine" , "mianserine" , "antipsychotica, atypische" , "nitrazepam" , "amisulpride" , "clobazam" , "dapoxetine" , "midazolam" , "chloorprotixeen" , "psychostimulantia" , "buprenorfine/naloxon" , "benzodiazepine agonisten" , "dosulepine" , "sertraline" , "methylfenidaat" , "nortriptyline" , "middelen bij verslavingsziekten" , "prazepam" , "clorazepinezuur" , "modafinil" , "middelen bij alcoholverslaving" , "broomperidol" , "zolpidem" , "melatonine" , "tranylcypromine" , "dexamfetamine" , "risperidon" , "diazepam" , "coffeïne", antipsychotica", antipsychotica, klassieke", brotizolam", paliperidon", varenicline", venlafaxine", fluoxetine", antidepressiva", periciazine", moclobemide", serotonineheropnameremmers, selectief", sertindol", amitriptyline", imipramine", fluvoxamine", antidepressiva, overige", paroxetine", duloxetine", cariprazine", psycholeptica", flunitrazepam", brexpiprazol", quetiapine", pimozide", flurazepam", lithium", buprenorfine (bij verslaving)", serotonineheropnameremmers, niet-selectief", aripiprazol", citalopram", clomipramine", temazepam", nicotine", loprazolam", lorazepam", middelen bij nicotineverslaving", psychofarmaca, overige", fluspirileen", lithiumzouten", melatonine agonisten", lormetazepam", flupentixol", clozapine", buspiron", bupropion", MAO-remmers, niet-selectief", methadon", vortioxetine", disulfiram", atomoxetine", lisdexamfetamine", zopiclon", acamprosaat", olanzapine", haloperidol", bromazepam", penfluridol", trazodon", pipamperon", escitalopram", MAO-A-remmers", middelen bij opioïdverslaving",  " laapmiddelen",  " ulpiride",  " irtazapine",  " ricyclische antidepressiva",  " sychostimulantia, overige",  " aprotiline",  " altrexon",  " gomelatine",  " urasidon",  " mfetaminen",  " sketamine (nasaal)",  " etracyclische antidepressiva",  " arbamazepine",  " hloralhydraat",  " roperidol (intramusculair)",  " oliumzuur",  " uanfacine",  " ydroxyzine",  " amotrigine",  " regabaline",  " ropranolol (cardiovasculair of neurologisch)",  " hiamine",  " aleriaan",  " alproïnezuur"}; List < String > drugNames = new ArrayList < > ( Arrays . asList ( drugNamesArray ) ) ; drugNames = drugNames . stream ( ) . map ( str -> str . toLowerCase ( ) ) . collect ( Collectors . toList ( ) ) ; drugFetcher . parseHtml ( ) ; List < String > expectedDrugs = drugDao . getAllDrugNames ( ) ; expectedDrugs . removeAll ( drugNames ) ; drugNames . removeAll ( drugDao . getAllDrugNames ( ) ) ; assertEquals ( drugNames , expectedDrugs ) ; }
Method that tests if drugFetcher correctly adds all expected drugs.
Method that tests if drugFetcher correctly adds all expected drugs .