Skip to content

Commit

Permalink
Added tests for getDependencies()
Browse files Browse the repository at this point in the history
  • Loading branch information
dschiese committed Oct 19, 2023
1 parent 892474b commit d4abda0
Showing 1 changed file with 53 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.*;

import static org.mockito.ArgumentMatchers.any;

Expand All @@ -47,7 +44,7 @@ public class AutomatedTestingServiceTest {


@Nested
class selectComponentTests {
class SelectComponentTests {

private final Random random = new Random();
private Example example;
Expand Down Expand Up @@ -100,7 +97,7 @@ public void selectComponentUniqueAndExisting() {
}

@Nested
class createDatasetTests {
class CreateDatasetTests {

/*
* Happy path: ResultSet not null
Expand Down Expand Up @@ -137,6 +134,56 @@ public void createDatasetResultSetIsNullTest() throws Exception {

Assertions.assertEquals("ResultSet is null", exception.getMessage());
}
}

@Nested
class GetDependenciesTests {

/*
* Happy path: No dependencies
* Sad path: Dependencies
* Result: List of Dependencies without (!) the origin AnnotationType (else the method would lead to a infinite loop)
*/

@ParameterizedTest
@EnumSource(AnnotationType.class)
public void getDependenciesTest(AnnotationType annotationType) {
ArrayList<AnnotationType> listOfDependencies = automatedTestingService.getDependencies(annotationType);
if (listOfDependencies != null)
Collections.sort(listOfDependencies);

switch (annotationType) {
case annotationofinstance:
case annotationofspotinstance:
case annotationofrelation:
case annotationofquestionlanguage: {
Assertions.assertNull(listOfDependencies);
break;
}
case annotationofanswersparql: {
ArrayList<AnnotationType> arrayList = new ArrayList<>() {{
add(AnnotationType.annotationofinstance);
add(AnnotationType.annotationofspotinstance);
add(AnnotationType.annotationofrelation);
}};
Assertions.assertEquals(arrayList, listOfDependencies);
break;
}
case annotationofanswerjson: {
ArrayList<AnnotationType> arrayList = new ArrayList<>() {{
add(AnnotationType.annotationofinstance);
add(AnnotationType.annotationofspotinstance);
add(AnnotationType.annotationofrelation);
add(AnnotationType.annotationofanswersparql);
}};
Assertions.assertEquals(arrayList, listOfDependencies);
break;
}
default: {
throw new RuntimeException("getDependenciesTest did not succeed");
}
}
}

}
}

0 comments on commit d4abda0

Please sign in to comment.