Skip to content

Commit

Permalink
Task1 - Implement service and acceptance tests
Browse files Browse the repository at this point in the history
- Reformatted unit test files.
  • Loading branch information
PietroSassone committed May 16, 2022
1 parent 46112db commit 844c110
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class ProductControllerTest {
@Mock
private ProductModelAssembler productModelAssemblerMock;

private final Function<Long, Link> addApiLinkToProduct = productId -> WebMvcLinkBuilder.linkTo(methodOn(ProductController.class).getProduct(productId)).withSelfRel();

private ProductController undertest;

@BeforeClass
Expand Down Expand Up @@ -229,6 +231,4 @@ private Object[][] negativeCaseProductIdsDataProvider() {
{0L}, {-1L}, {null}
};
}

private final Function<Long, Link> addApiLinkToProduct = productId -> WebMvcLinkBuilder.linkTo(methodOn(ProductController.class).getProduct(productId)).withSelfRel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public class UserControllerTest {
@Mock
private KafkaProducer kafkaProducerMock;

private final Function<String, Link> addApiLinkToUser = userName -> WebMvcLinkBuilder.linkTo(methodOn(UserController.class).getUser(userName)).withSelfRel();

private final Function<UserChangeReason, Void> verifyKafkaProducerSendingEventWithReason = changeReason -> {
final ArgumentCaptor<UserOperationNotificationEvent> valueCapture = getArgumentCaptorForKafkaEvent();

verify(kafkaProducerMock).sendUserChangeEvent(any(), valueCapture.capture());
assertEquals(valueCapture.getValue().getChangeReason(), changeReason);
return null;
};

private UserController undertest;

@BeforeClass
Expand Down Expand Up @@ -266,17 +276,7 @@ private Object[][] negativeCaseUserIdsDataProvider() {
};
}

private final Function<String, Link> addApiLinkToUser = userName -> WebMvcLinkBuilder.linkTo(methodOn(UserController.class).getUser(userName)).withSelfRel();

private ArgumentCaptor<UserOperationNotificationEvent> getArgumentCaptorForKafkaEvent() {
return ArgumentCaptor.forClass(UserOperationNotificationEvent.class);
}

private final Function<UserChangeReason, Void> verifyKafkaProducerSendingEventWithReason = changeReason -> {
final ArgumentCaptor<UserOperationNotificationEvent> valueCapture = getArgumentCaptorForKafkaEvent();

verify(kafkaProducerMock).sendUserChangeEvent(any(), valueCapture.capture());
assertEquals(valueCapture.getValue().getChangeReason(), changeReason);
return null;
};
}

0 comments on commit 844c110

Please sign in to comment.