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

OZG-4461 OZG-4511 fix test

parent a9a33411
No related branches found
No related tags found
No related merge requests found
......@@ -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)
public void onCommandExecuteProcessor(CommandCreatedEvent event) {
try {
......@@ -88,11 +83,16 @@ class ProcessorEventListener {
return result.toBuilder().vorgangId(VorgangId.from(vorgangId)).build();
}
void publishCommandFailedEvent(Throwable e, String commandId) {
publisher.publishEvent(new CommandFailedEvent(commandId, e.getMessage()));
private void handleError(Throwable cause, String vorgangId) {
LOG.error("Error on procession Vorgang {} externally", vorgangId, cause);
resultService.processError(cause, vorgangId);
}
void publishCommandProcessedEvent(Command 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.*;
import static org.mockito.Mockito.*;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
......@@ -210,14 +210,20 @@ class ProcessorEventListenerTest {
}
}
@Disabled("FIXME: Er geht nicht in den catch block rein")
@DisplayName("On ViolationConstraint exception")
@Nested
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
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment