diff --git a/goofy-server/src/main/java/de/itvsh/goofy/common/command/CommandController.java b/goofy-server/src/main/java/de/itvsh/goofy/common/command/CommandController.java index e61931fb1db125288414a0b2e34422316af99ec6..f02f000c3e3f93d9b4a151c3fc50c9e0e2e958dc 100644 --- a/goofy-server/src/main/java/de/itvsh/goofy/common/command/CommandController.java +++ b/goofy-server/src/main/java/de/itvsh/goofy/common/command/CommandController.java @@ -16,10 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import de.itvsh.goofy.postfach.PostfachMail; -import de.itvsh.goofy.postfach.PostfachMailController; -import de.itvsh.goofy.vorgang.VorgangController; -import de.itvsh.goofy.vorgang.VorgangWithEingang; import lombok.Getter; @RestController @@ -72,10 +68,6 @@ public class CommandController { @Autowired private CommandService service; - @Autowired - private VorgangController vorgangController; - @Autowired - private PostfachMailController postfachController; @PostMapping public ResponseEntity<Void> createCommand(@PathVariable String vorgangId, @PathVariable String relationId, @@ -83,10 +75,6 @@ public class CommandController { command = command.toBuilder().vorgangId(vorgangId).relationId(relationId).build(); var created = createCommand(command, relationVersion); - if (isSendPostfachMailOrder(command)) { - sendPostfachMail(created.getId(), buildPostfachMail(command)); - } - return ResponseEntity.created(linkTo(CommandController.class).slash(created.getId()).toUri()).build(); } @@ -101,28 +89,5 @@ public class CommandController { public Command createCommandWithoutValidation(CreateCommand command, String itemName) { return service.createCommandWithoutValidation(command, itemName); } - - private boolean isSendPostfachMailOrder(CreateCommand command) { - return command.getOrder() == CommandOrder.SEND_POSTFACH_MAIL || command.getOrder() == CommandOrder.SEND_POSTFACH_NACHRICHT; - } - - void sendPostfachMail(String commandId, PostfachMail postfachMail) { - postfachController.sendPostfachMail(commandId, postfachMail); - } - - private PostfachMail buildPostfachMail(CreateCommand command) { - return ((PostfachMail) command.getBody()).toBuilder() - .vorgangId(command.getVorgangId()) - .postfachId(getPostfachId(command.getVorgangId())) - .build(); - } - - private String getPostfachId(String vorgangId) { - return getVorgang(vorgangId).getEingang().getAntragsteller().getPostfachId(); - } - - private VorgangWithEingang getVorgang(String vorgangId) { - return vorgangController.getVorgang(vorgangId); - } } } \ No newline at end of file diff --git a/goofy-server/src/test/java/de/itvsh/goofy/common/command/CommandControllerTest.java b/goofy-server/src/test/java/de/itvsh/goofy/common/command/CommandControllerTest.java index 374b8d535dc8bbce3fd168e13936d38944ba1401..e98357d2cfd302867c266da614d38687a35db42b 100644 --- a/goofy-server/src/test/java/de/itvsh/goofy/common/command/CommandControllerTest.java +++ b/goofy-server/src/test/java/de/itvsh/goofy/common/command/CommandControllerTest.java @@ -25,12 +25,8 @@ import static org.assertj.core.api.Assertions.*; import de.itvsh.goofy.common.command.CommandController.CommandByRelationController; import de.itvsh.goofy.common.errorhandling.ExceptionController; -import de.itvsh.goofy.postfach.PostfachMail; -import de.itvsh.goofy.postfach.PostfachMailController; -import de.itvsh.goofy.postfach.PostfachMailTestFactory; import de.itvsh.goofy.vorgang.VorgangController; import de.itvsh.goofy.vorgang.VorgangHeaderTestFactory; -import de.itvsh.goofy.vorgang.VorgangWithEingangTestFactory; import de.itvsh.kop.common.test.TestUtils; class CommandControllerTest { @@ -126,10 +122,6 @@ class CommandControllerTest { private CommandService service; @Mock private CommandModelAssembler modelAssembler; - @Mock - private VorgangController vorgangController; - @Mock - private PostfachMailController postfachController; private MockMvc mockMvc; @@ -172,50 +164,6 @@ class CommandControllerTest { .andExpect(header().stringValues("location", "http://localhost" + COMMANDS_PATH + "/" + CommandTestFactory.ID)); } - @Nested - @DisplayName("CreateCommand with postfach mail") - class WithPostfachMail { - - @BeforeEach - void mockVorgangController() { - when(vorgangController.getVorgang(anyString())).thenReturn(VorgangWithEingangTestFactory.create()); - } - - @Test - void shouldHavePostfachMail() throws Exception { - doRequest(PostfachMailTestFactory.buildSendPostfachMailContent()); - - verify(service).createCommand(createCommandCaptor.capture(), anyLong()); - assertThat(createCommandCaptor.getValue()).extracting(CreateCommand::getBody).usingRecursiveComparison() - .ignoringFields("id", "vorgangId", "postfachId", "createdAt", "createdBy", "direction", "sentAt", "sentSuccessful", - "messageCode", - "attachments") // TODO remove this when sending attachments - .isEqualTo(PostfachMailTestFactory.create()); - } - - @Test - void shouldCallVorgangController() throws Exception { - doRequest(PostfachMailTestFactory.buildSendPostfachMailContent()); - - verify(vorgangController).getVorgang(VorgangHeaderTestFactory.ID); - } - - @Test - void shouldCallPostfachController() throws Exception { - doRequest(PostfachMailTestFactory.buildSendPostfachMailContent()); - - verify(postfachController).sendPostfachMail(anyString(), any(PostfachMail.class)); - } - - @Test - void shouldCallPostfachControllerOnNewOrder() throws Exception { - doRequest(PostfachMailTestFactory.buildSendPostfachMailContent(PostfachMailTestFactory.create(), - CommandOrder.SEND_POSTFACH_NACHRICHT)); - - verify(postfachController).sendPostfachMail(anyString(), any(PostfachMail.class)); - } - } - private ResultActions doRequest() throws Exception { return doRequest( TestUtils.loadTextFile("jsonTemplates/command/createVorgangCommand.json.tmpl", CommandOrder.VORGANG_ANNEHMEN.name()));