Skip to content
Snippets Groups Projects
Commit d856170b authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4461 OZG-4511 fix test

parent a9a33411
Branches
Tags
No related merge requests found
...@@ -52,11 +52,6 @@ class ProcessorEventListener { ...@@ -52,11 +52,6 @@ class ProcessorEventListener {
} }
} }
private void handleError(Throwable cause, String vorgangId) {
LOG.error("Error on procession Vorgang {} externally", vorgangId, cause);
resultService.processError(cause, vorgangId);
}
@EventListener(condition = IS_EXECUTE_PROCESSOR) @EventListener(condition = IS_EXECUTE_PROCESSOR)
public void onCommandExecuteProcessor(CommandCreatedEvent event) { public void onCommandExecuteProcessor(CommandCreatedEvent event) {
try { try {
...@@ -88,11 +83,16 @@ class ProcessorEventListener { ...@@ -88,11 +83,16 @@ class ProcessorEventListener {
return result.toBuilder().vorgangId(VorgangId.from(vorgangId)).build(); return result.toBuilder().vorgangId(VorgangId.from(vorgangId)).build();
} }
void publishCommandFailedEvent(Throwable e, String commandId) { private void handleError(Throwable cause, String vorgangId) {
publisher.publishEvent(new CommandFailedEvent(commandId, e.getMessage())); LOG.error("Error on procession Vorgang {} externally", vorgangId, cause);
resultService.processError(cause, vorgangId);
} }
void publishCommandProcessedEvent(Command command) { void publishCommandProcessedEvent(Command command) {
publisher.publishEvent(new CommandProcessedEvent(command)); publisher.publishEvent(new CommandProcessedEvent(command));
} }
void publishCommandFailedEvent(Throwable e, String commandId) {
publisher.publishEvent(new CommandFailedEvent(commandId, e.getMessage()));
}
} }
\ No newline at end of file
...@@ -5,12 +5,12 @@ import static org.mockito.ArgumentMatchers.*; ...@@ -5,12 +5,12 @@ import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -210,14 +210,20 @@ class ProcessorEventListenerTest { ...@@ -210,14 +210,20 @@ class ProcessorEventListenerTest {
} }
} }
@Disabled("FIXME: Er geht nicht in den catch block rein")
@DisplayName("On ViolationConstraint exception") @DisplayName("On ViolationConstraint exception")
@Nested @Nested
class TestOnViolationConstraintException { class TestOnViolationConstraintException {
private final Mono<ProcessorResult> processorResults = Mono.just(ProcessorResultTestFactory.create());
private final Stream<Mono<ProcessorResult>> monoStream = Stream.of(processorResults);
private final ConstraintViolationException exception = new ConstraintViolationException("", Collections.emptySet());
@BeforeEach @BeforeEach
void init(){ void init(){
doThrow(ConstraintViolationException.class).when(resultService).processResult(any()); when(vorgangService.getVorgang(any())).thenReturn(vorgang);
when(processorService.processVorgang(any(), any())).thenReturn(monoStream);
doThrow(exception).when(vorgangEventListener).processResult(any(), any());
doNothing().when(vorgangEventListener).publishCommandFailedEvent(any(), any());
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment