Skip to content

Commit

Permalink
Merge branch 'feature/576-toaster-styling' of github.com:puzzle/okr i…
Browse files Browse the repository at this point in the history
…nto feature/576-toaster-styling
  • Loading branch information
kcinay055679 committed Nov 24, 2023
2 parents b0c359a + 8e596ce commit 3bd6273
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package ch.puzzle.okr.service.persistence;

import ch.puzzle.okr.TestHelper;
import ch.puzzle.okr.dto.ErrorDto;
import ch.puzzle.okr.models.Action;
import ch.puzzle.okr.models.Objective;
import ch.puzzle.okr.models.OkrResponseStatusException;
import ch.puzzle.okr.models.keyresult.KeyResultMetric;
import ch.puzzle.okr.test.SpringIntegrationTest;
import org.junit.jupiter.api.AfterEach;
Expand All @@ -11,6 +14,7 @@

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;

Expand Down Expand Up @@ -79,10 +83,13 @@ void updateActionShouldThrowExceptionWhenAlreadyUpdated() {
Action changedAction = createAction(createdAction.getId(), 0);
changedAction.setAction("Updated Action");

ResponseStatusException exception = assertThrows(ResponseStatusException.class,
OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class,
() -> actionPersistenceService.save(changedAction));
List<ErrorDto> expectedErrors = List.of(new ErrorDto("DATA_HAS_BEEN_UPDATED", List.of("Action")));

assertEquals(UNPROCESSABLE_ENTITY, exception.getStatus());
assertTrue(exception.getReason().contains("updated or deleted by another user"));
assertThat(expectedErrors).hasSameElementsAs(exception.getErrors());
assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ void updateTeamShouldThrowExceptionWhenAlreadyUpdated() {
Team changedTeam = Team.Builder.builder().withId(createdTeam.getId()).withVersion(0).withName("Changed Team")
.build();

ResponseStatusException exception = assertThrows(ResponseStatusException.class,
OkrResponseStatusException exception = assertThrows(OkrResponseStatusException.class,
() -> teamPersistenceService.save(changedTeam));
List<ErrorDto> expectedErrors = List.of(new ErrorDto("DATA_HAS_BEEN_UPDATED", List.of("Team")));

assertEquals(UNPROCESSABLE_ENTITY, exception.getStatus());
assertTrue(exception.getReason().contains("updated or deleted by another user"));
assertThat(expectedErrors).hasSameElementsAs(exception.getErrors());
assertTrue(TestHelper.getAllErrorKeys(expectedErrors).contains(exception.getReason()));
}

@Test
Expand Down

0 comments on commit 3bd6273

Please sign in to comment.