-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Add backend tests
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -167,6 +167,33 @@ void testBulkInject() { | |
tests.forEach(test -> this.injectTestStatusService.deleteInjectTest(test.getId())); | ||
} | ||
|
||
@DisplayName("Bulk test with non testable injects") | ||
@Test | ||
void bulkTestNonMailInject() { | ||
// Mock the UserDetails with a custom ID | ||
User user = this.userRepository.findByEmailIgnoreCase("[email protected]").orElseThrow(); | ||
OpenBASOidcUser oidcUser = new OpenBASOidcUser(user); | ||
Authentication auth = new UsernamePasswordAuthenticationToken(oidcUser, "password", Collections.EMPTY_LIST); | ||
SecurityContextHolder.getContext().setAuthentication(auth); | ||
|
||
// -- EXECUTE -- | ||
Exception exception = assertThrows(IllegalArgumentException.class, () -> { | ||
injectTestStatusService.bulkTestInjects(Collections.singletonList(INJECT3.getId())); | ||
}); | ||
|
||
String expectedMessage = "No inject ID is testable"; | ||
String actualMessage = exception.getMessage(); | ||
assertTrue(actualMessage.contains(expectedMessage)); | ||
|
||
// -- CLEAN -- | ||
SearchPaginationInput searchPaginationInput = PaginationFixture.getDefault() | ||
.size(1110) | ||
.build(); | ||
Page<InjectTestStatus> tests = injectTestStatusService.findAllInjectTestsByExerciseId(EXERCISE.getId(), | ||
searchPaginationInput); | ||
tests.stream().forEach(test -> this.injectTestStatusService.deleteInjectTest(test.getId())); | ||
} | ||
|
||
@DisplayName("Check the number of tests of an exercise") | ||
@Test | ||
void findAllInjectTestsByExerciseId() { | ||
|