Skip to content

Commit

Permalink
TRIB-222: adds codecoverage test in review empty
Browse files Browse the repository at this point in the history
- adds getUserPhrasesToBeReviewedHappyPathNoPhrases()
  • Loading branch information
mrsbluerose committed Dec 4, 2023
1 parent 54e51d5 commit dd14e67
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
import org.springframework.web.context.WebApplicationContext;

import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.*;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -368,4 +365,30 @@ public void getUserPhrasesToBeReviewedHappyPath() throws Exception {
assertThat(actualAttributes).usingRecursiveComparison().isEqualTo(expectedToBeReviewed);
}

@Test
public void getUserPhrasesToBeReviewedHappyPathNoPhrases() throws Exception {
Mockito.when(userPrincipalService.getUserPrincipalByEmail(Mockito.anyString()))
.thenReturn(new UserPrincipal(user));
String auth = AuthServiceImpl.generateAccessToken(user);
Long userId = 1L;

when(reviewSubmittingUserService.getUserPhrasesToBeReviewed(anyLong())).thenReturn(new ArrayList<>());

MvcResult result =
this.mockMvc
.perform(
get("/api/attributes/in-review/{userId}", userId)
.header("Authorization", "Bearer " + auth)
.characterEncoding("utf-8"))
.andExpect(status().isOk())
.andReturn();

Type toBeReviewedDTOListType = new TypeToken<List<ToBeReviewedDTO>>() {
}.getType();

List<ToBeReviewedDTO> actualAttributes =
gson.fromJson(result.getResponse().getContentAsString(), toBeReviewedDTOListType);
assertThat(actualAttributes).isEmpty();
}

}

0 comments on commit dd14e67

Please sign in to comment.