src/test/java/nl/bioinf/minorapplicationdesign/ontpillen/model/web_scraping/DrugFetcherTest.java
/**
     * Method that tests if drugFetcher correctly adds all expected drug groups. The expected drug group list and the actual
     * drug group list are compared independent of order.
     * @throws IOException
     */
Method that tests if drugFetcher correctly adds all expected drug groups. The expected drug group list and the actual
drug group list are compared independent of order.
Method that tests if drugFetcher correctly adds all expected drug groups . The expected drug group list and the actual drug group list are compared independent of order .
@Test
    void parseHtml_scrapeDrugs_CheckDrugGroups() throws IOException {
        String[] drugGroupsArray = {"antidepressiva", "middelen bij verslavingsziekten", "psychofarmaca, overige", "psycholeptica", "psychostimulantia", "slaapmiddelen"};
        ArrayList<String> drugGroupsExpected = new ArrayList<>(Arrays.asList(drugGroupsArray));
        drugFetcher.parseHtml();
        List<DrugGroup> drugGroupsDao = drugDao.getMainDrugGroups();
        List<String> drugGroupsActual = new ArrayList<>();
        for (DrugGroup drugGroup: drugGroupsDao) {
            drugGroupsActual.add(drugGroup.getName());
        }
        drugGroupsActual.removeAll(drugGroupsExpected);
        drugGroupsExpected.removeAll(Arrays.asList(drugGroupsArray));
        assertEquals(drugGroupsActual, drugGroupsExpected);
    }
@ Test void parseHtml_scrapeDrugs_CheckDrugGroups ( ) throws IOException { String [ ] drugGroupsArray = { "antidepressiva" , "middelen bij verslavingsziekten" , "psychofarmaca, overige" , "psycholeptica" , "psychostimulantia" , "slaapmiddelen" } ; ArrayList < String > drugGroupsExpected = new ArrayList < > ( Arrays . asList ( drugGroupsArray ) ) ; drugFetcher . parseHtml ( ) ; List < DrugGroup > drugGroupsDao = drugDao . getMainDrugGroups ( ) ; List < String > drugGroupsActual = new ArrayList < > ( ) ; for ( DrugGroup drugGroup : drugGroupsDao ) { drugGroupsActual . add ( drugGroup . getName ( ) ) ; } drugGroupsActual . removeAll ( drugGroupsExpected ) ; drugGroupsExpected . removeAll ( Arrays . asList ( drugGroupsArray ) ) ; assertEquals ( drugGroupsActual , drugGroupsExpected ) ; }
Method that tests if drugFetcher correctly adds all expected drug groups.
Method that tests if drugFetcher correctly adds all expected drug groups .