Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add backend tests
Browse files Browse the repository at this point in the history
johanah29 committed Sep 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent cb63304 commit e093b20
Showing 1 changed file with 27 additions and 0 deletions.
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() {

0 comments on commit e093b20

Please sign in to comment.