Skip to content

Commit

Permalink
backend formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel7373 committed Jan 7, 2025
1 parent bfb9128 commit 1e7a383
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package ch.puzzle.okr.service.business;

import static org.springframework.http.HttpStatus.NOT_FOUND;

import ch.puzzle.okr.exception.OkrResponseStatusException;
import ch.puzzle.okr.models.Completed;
import ch.puzzle.okr.service.persistence.CompletedPersistenceService;
import ch.puzzle.okr.service.validation.CompletedValidationService;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;

import static org.springframework.http.HttpStatus.NOT_FOUND;

@Service
public class CompletedBusinessService {
private final CompletedPersistenceService completedPersistenceService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doThrow;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand Down Expand Up @@ -33,13 +34,6 @@
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.web.server.ResponseStatusException;

import static ch.puzzle.okr.test.KeyResultTestHelpers.JSON_PATH_ID;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doThrow;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

@WithMockUser(value = "spring")
@ExtendWith(MockitoExtension.class)
@WebMvcTest(CompletedController.class)
Expand Down Expand Up @@ -133,17 +127,20 @@ void deleteShouldThrowExceptionWhenCompletedWithIdCantBeFound() throws Exception
@DisplayName("get() should get Completed by Objective id")
@Test
void shouldGetMetricCompletedWithId() throws Exception {
mvc.perform(get("/api/v2/completed/1").with(SecurityMockMvcRequestPostProcessors.csrf()))
mvc
.perform(get("/api/v2/completed/1").with(SecurityMockMvcRequestPostProcessors.csrf()))
.andExpect(MockMvcResultMatchers.status().isOk());
}

@DisplayName("get() should throw exception when Completed with id cant be found")
@Test
void getShouldThrowExceptionWhenCompletedWithIdCantBeFound() throws Exception {
doThrow(new ResponseStatusException(HttpStatus.NOT_FOUND, "Completed not found"))
.when(completedAuthorizationService).getCompletedByObjectiveId(anyLong());
.when(completedAuthorizationService)
.getCompletedByObjectiveId(anyLong());

mvc.perform(get("/api/v2/completed/1000").with(SecurityMockMvcRequestPostProcessors.csrf()))
mvc
.perform(get("/api/v2/completed/1000").with(SecurityMockMvcRequestPostProcessors.csrf()))
.andExpect(MockMvcResultMatchers.status().isNotFound());
}
}

0 comments on commit 1e7a383

Please sign in to comment.