src/test/java/nl/bioinf/minorapplicationdesign/ontpillen/model/web_scraping/DrugFetcherTest.java
/**
     * Method that tests if drugFetcher correctly adds all expected drug substances. The expected drug substances list and the actual
     * drug substances list are compared independent of order.
     * @throws IOException
     */
Method that tests if drugFetcher correctly adds all expected drug substances. The expected drug substances list and the actual
drug substances list are compared independent of order.
Method that tests if drugFetcher correctly adds all expected drug substances . The expected drug substances list and the actual drug substances list are compared independent of order .
@Test
    void parseHtml_scrapeDrugs_CheckDrugSubstance() throws IOException {
        String[] drugSubstanceArray = {"buspiron", "bupropion", "esketamine (nasaal)", "vortioxetine", "lithium", "moclobemide", "fenelzine", "tranylcypromine", "agomelatine", "melatonine", "duloxetine", "trazodon", "venlafaxine", "citalopram", "dapoxetine", "escitalopram", "fluoxetine", "fluvoxamine", "paroxetine", "sertraline", "mianserine", "mirtazapine", "amitriptyline", "clomipramine", "dosulepine", "imipramine", "maprotiline", "nortriptyline", "acamprosaat", "disulfiram", "nalmefeen", "naltrexon", "nicotine", "varenicline", "buprenorfine (bij verslaving)", "buprenorfine/naloxon", "methadon", "dexamfetamine", "lisdexamfetamine", "methylfenidaat", "atomoxetine", "coffeïne", "modafinil", "alprazolam", "bromazepam", "brotizolam", "clobazam", "clorazepinezuur", "diazepam", "flunitrazepam", "flurazepam", "loprazolam", "lorazepam", "lormetazepam", "midazolam", "nitrazepam", "oxazepam", "prazepam", "temazepam", "zolpidem", "zopiclon", "aripiprazol", "brexpiprazol", "cariprazine", "clozapine", "lurasidon", "olanzapine", "paliperidon", "quetiapine", "risperidon", "sertindol", "amisulpride", "broomperidol", "chloorprotixeen", "flupentixol", "fluspirileen", "haloperidol", "penfluridol", "periciazine", "pimozide", "pipamperon", "sulpiride", "zuclopentixol", "carbamazepine", "chloralhydraat", "droperidol (intramusculair)", "foliumzuur", "guanfacine", "hydroxyzine", "lamotrigine", "pregabaline", "propranolol (cardiovasculair of neurologisch)", "thiamine", "valeriaan", "valproïnezuur"};
        ArrayList<String> drugSubstancesExpected = new ArrayList<>(Arrays.asList(drugSubstanceArray));
        drugFetcher.parseHtml();
        List<DrugSubstance> drugGroupsInDao = drugDao.getDrugSubstances();
        List<String> drugSubstancesActual = new ArrayList<>();
        for (DrugSubstance drugSubstance: drugGroupsInDao) {
            drugSubstancesActual.add(drugSubstance.getName());
        }
        drugSubstancesActual.removeAll(drugSubstancesExpected);
        drugSubstancesExpected.removeAll(Arrays.asList(drugSubstanceArray));
        assertEquals(drugSubstancesActual, drugSubstancesExpected);
    }
@ Test void parseHtml_scrapeDrugs_CheckDrugSubstance ( ) throws IOException { String [ ] drugSubstanceArray = { "buspiron" , "bupropion" , "esketamine (nasaal)" , "vortioxetine" , "lithium" , "moclobemide" , "fenelzine" , "tranylcypromine" , "agomelatine" , "melatonine" , "duloxetine" , "trazodon" , "venlafaxine" , "citalopram" , "dapoxetine" , "escitalopram" , "fluoxetine" , "fluvoxamine" , "paroxetine" , "sertraline" , "mianserine" , "mirtazapine" , "amitriptyline" , "clomipramine" , "dosulepine" , "imipramine" , "maprotiline" , "nortriptyline" , "acamprosaat" , "disulfiram" , "nalmefeen" , "naltrexon" , "nicotine" , "varenicline" , "buprenorfine (bij verslaving)" , "buprenorfine/naloxon" , "methadon" , "dexamfetamine" , "lisdexamfetamine" , "methylfenidaat" , "atomoxetine" , "coffeïne", modafinil", alprazolam", bromazepam", brotizolam", clobazam", clorazepinezuur", diazepam", flunitrazepam", flurazepam", loprazolam", lorazepam", lormetazepam", midazolam", nitrazepam", oxazepam", prazepam", temazepam", zolpidem", zopiclon", aripiprazol", brexpiprazol", cariprazine", clozapine", lurasidon", olanzapine", paliperidon", quetiapine", risperidon", sertindol", amisulpride", broomperidol", chloorprotixeen", flupentixol", fluspirileen", haloperidol", penfluridol", periciazine", pimozide", pipamperon", sulpiride", zuclopentixol", carbamazepine", chloralhydraat", droperidol (intramusculair)", foliumzuur", guanfacine", hydroxyzine", lamotrigine", pregabaline", propranolol (cardiovasculair of neurologisch)", thiamine", valeriaan", valproïnezuur"}; ArrayList < String > drugSubstancesExpected = new ArrayList < > ( Arrays . asList ( drugSubstanceArray ) ) ; drugFetcher . parseHtml ( ) ; List < DrugSubstance > drugGroupsInDao = drugDao . getDrugSubstances ( ) ; List < String > drugSubstancesActual = new ArrayList < > ( ) ; for ( DrugSubstance drugSubstance : drugGroupsInDao ) { drugSubstancesActual . add ( drugSubstance . getName ( ) ) ; } drugSubstancesActual . removeAll ( drugSubstancesExpected ) ; drugSubstancesExpected . removeAll ( Arrays . asList ( drugSubstanceArray ) ) ; assertEquals ( drugSubstancesActual , drugSubstancesExpected ) ; }
Method that tests if drugFetcher correctly adds all expected drug substances.
Method that tests if drugFetcher correctly adds all expected drug substances .