Commit 0e22b472 authored by Simhadri Guntreddi's avatar Simhadri Guntreddi

Added component test case

parent 760e43e1
......@@ -69,6 +69,24 @@ public class TransactionControllerTest {
Assertions.assertEquals(responseEntity.getBody(), Arrays.asList(new Offsets()));
}
@Test
public void testProducer_WhenIsProcessed_False() {
listOfOffest = new ArrayList<>();
Offsets offsets = new Offsets();
offsets.setPartition("0");
offsets.setOffset("1");
listOfOffest.add(offsets);
UUID uuid = UUID.fromString(transactionId);
Optional<TransactionRecorder> optionalOfferTransaction = Optional.of(createTransactionRecorderIsProcessedFalse(uuid));
Mockito.when(transactionRepository.findById(Mockito.any(UUID.class))).thenReturn(optionalOfferTransaction);
Mockito.when(producerService.produce(Mockito.any(TransactionPayload.class), Mockito.anyString(),
Mockito.any(TransactionRecorder.class), Mockito.anyBoolean())).thenReturn(listOfOffest);
ResponseEntity<List<Offsets>> responseEntity = transactionController.produce(transactionId);
Assertions.assertEquals(responseEntity.getStatusCode(), HttpStatus.OK);
}
private TransactionRecorder createTransactionRecorder(UUID uuid) {
TransactionRecorder transactionRecorder = new TransactionRecorder();
transactionRecorder.setUuid(uuid);
......@@ -77,5 +95,13 @@ public class TransactionControllerTest {
transactionRecorder.setOfferTransactionResponse("TransactionResponse");
return transactionRecorder;
}
private TransactionRecorder createTransactionRecorderIsProcessedFalse(UUID uuid) {
TransactionRecorder transactionRecorder = new TransactionRecorder();
transactionRecorder.setUuid(uuid);
transactionRecorder.setProcessed(false);
transactionRecorder.setOffers("offers");
transactionRecorder.setOfferTransactionResponse("TransactionResponse");
return transactionRecorder;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment