-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added APICharityScraperTest test class.
Added testclass for the scraper with some test methods.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...helpapplication/src/test/java/ntnu/sytemutvikling/team6/models/APICharityScraperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.URISyntaxException; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| class APICharityScraperTest { | ||
| @Test | ||
| void connectionToDataBaseShouldReturnTrue() throws IOException, URISyntaxException { | ||
| var con = new APICharityScraper(); | ||
|
|
||
| assertTrue(con.checkConnection(), "Get response should be 200 (success)"); | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| void ParsedJSONShouldHaveCorrectValues() throws IOException, URISyntaxException { | ||
| var con = new APICharityScraper(); | ||
| String JSONData = "[{\"org_number\":\"938419264\",\"name\":\"Misjonsalliansen\",\"status\":\"approved\"," + | ||
| "\"url\":\"https:\\/\\/www.innsamlingskontrollen.no\\/organisasjoner\\/misjonsalliansen\\/\"," + | ||
| "\"is_pre_approved\":false}]"; | ||
| var list = con.parseJSON(JSONData); | ||
|
|
||
| assertEquals("938419264", list.getFirst().getOrg_number(), | ||
| "Parsed organization number should be correct."); | ||
| assertEquals("Misjonsalliansen", list.getFirst().getName(), | ||
| "Parsed name should be correct"); | ||
| assertEquals("approved", list.getFirst().getStatus(), | ||
| "Parsed status should be correct."); | ||
| assertEquals("https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", | ||
| list.getFirst().getUrl(), "Parsed url should be correct."); | ||
| assertFalse(list.getFirst().getIs_pre_approved(), "Parsed is_pre_approved boolean should " + | ||
| "be correct."); | ||
| } | ||
|
|
||
| } |