Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
msdousti committed Sep 22, 2024
1 parent 66a9b2b commit c9e8ba9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ public void filter(final ContainerRequestContext request, final ContainerRespons

read(request::getProperty, "process-response", ResponseProcessingStage.class)
.ifPresent(context.hasEntity() ?
throwingConsumer(stage ->
request.setProperty("write-response", stage.process(response))) :
throwingConsumer(stage -> {
request.setProperty("write-response", stage.process(response));
response.expose();
}) :
throwingConsumer(stage ->
stage.process(response).write()));

if (context.hasEntity())
response.expose();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerResponseContext;
import jakarta.ws.rs.container.ContainerResponseFilter;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.junit.jupiter.api.Test;
import org.zalando.logbook.Logbook;

import java.io.IOException;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

final class LogbookServerFilterTest {

Expand All @@ -21,10 +19,8 @@ final class LogbookServerFilterTest {

private final ContainerResponseFilter unit = new LogbookServerFilter(logbook);

@ParameterizedTest
@ValueSource(booleans = {true, false})
void filterShouldDoNothingIfCorrelatorIsNotPresent(boolean hasEntity) throws IOException {
when(response.hasEntity()).thenReturn(hasEntity);
@Test
void filterShouldDoNothingIfCorrelatorIsNotPresent() throws IOException {
unit.filter(request, response);
verifyNoInteractions(logbook);
}
Expand Down

0 comments on commit c9e8ba9

Please sign in to comment.