public class RegisterForPnfReadyEventTest {
private static final String PNF_NAME = "pnfNameTest";
+ private static final String PNF_ENTRY_NOTIFICATION_TIMEOUT = "P14D";
+ private static final String PROCESS_INSTANCE_ID = "testInstanceId";
private DelegateExecution delegateExecution;
private ExtractPojosForBB extractPojosForBBMock;
- private DmaapClientTestImpl dmaapClientTest;
+ private KafkaClientTestImpl kafkaClientTest;
private MessageCorrelationBuilder messageCorrelationBuilder;
private ExceptionBuilder exceptionBuilderMock;
private BuildingBlockExecution buildingBlockExecution;
- private static final String PNF_ENTRY_NOTIFICATION_TIMEOUT = "P14D";
private RegisterForPnfReadyEvent testedObject;
@Before
public void init() {
delegateExecution = prepareExecution();
- dmaapClientTest = new DmaapClientTestImpl();
+ kafkaClientTest = new KafkaClientTestImpl();
exceptionBuilderMock = mock(ExceptionBuilder.class);
extractPojosForBBMock = mock(ExtractPojosForBB.class);
buildingBlockExecution = new DelegateExecutionImpl(new HashMap<>());
}
@Test
- public void shouldRegisterForDmaapClient() throws BBObjectNotFoundException {
+ public void shouldRegisterForKafkaClient() throws BBObjectNotFoundException {
// given
- testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock,
+ testedObject = new RegisterForPnfReadyEvent(kafkaClientTest, extractPojosForBBMock, exceptionBuilderMock,
PNF_ENTRY_NOTIFICATION_TIMEOUT);
Pnf pnf = new Pnf();
pnf.setPnfName(PNF_NAME);
verify(delegateExecution).setVariable(ExecutionVariableNames.PNF_CORRELATION_ID, PNF_NAME);
verify(delegateExecution).setVariable(ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION,
PNF_ENTRY_NOTIFICATION_TIMEOUT);
- checkIfInformConsumerThreadIsRunProperly(dmaapClientTest);
+ checkIfInformConsumerThreadIsRunProperly(kafkaClientTest);
}
@Test
public void pnfNotFoundInBBexecution_WorkflowExIsThrown() throws BBObjectNotFoundException {
// given
- testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock,
+ testedObject = new RegisterForPnfReadyEvent(kafkaClientTest, extractPojosForBBMock, exceptionBuilderMock,
PNF_ENTRY_NOTIFICATION_TIMEOUT);
when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF))
.thenThrow(BBObjectNotFoundException.class);
testedObject.execute(delegateExecution);
// then
verify(exceptionBuilderMock).buildAndThrowWorkflowException(delegateExecution, 7000,
- "pnf resource not found in buildingBlockExecution while registering to dmaap listener");
+ "pnf resource not found in buildingBlockExecution while registering to kafka listener");
}
@Test
public void pnfNameIsNull_WorkflowExIsThrown() throws BBObjectNotFoundException {
// given
- testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock,
+ testedObject = new RegisterForPnfReadyEvent(kafkaClientTest, extractPojosForBBMock, exceptionBuilderMock,
PNF_ENTRY_NOTIFICATION_TIMEOUT);
when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(new Pnf());
// when
@Test
public void pnfEventNotificationTimeoutNotSet_WorkflowExIsThrown() throws BBObjectNotFoundException {
// given
- testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock, null);
+ testedObject = new RegisterForPnfReadyEvent(kafkaClientTest, extractPojosForBBMock, exceptionBuilderMock, null);
when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(new Pnf());
// when
testedObject.execute(delegateExecution);
"pnfEntryNotificationTimeout value not defined");
}
- private void checkIfInformConsumerThreadIsRunProperly(DmaapClientTestImpl dmaapClientTest) {
- dmaapClientTest.getInformConsumer().run();
+ private void checkIfInformConsumerThreadIsRunProperly(KafkaClientTestImpl kafkaClientTest) {
+ kafkaClientTest.getInformConsumer().run();
InOrder inOrder = inOrder(messageCorrelationBuilder);
- inOrder.verify(messageCorrelationBuilder).processInstanceBusinessKey("testBusinessKey");
+ inOrder.verify(messageCorrelationBuilder).processInstanceId(PROCESS_INSTANCE_ID);
inOrder.verify(messageCorrelationBuilder).correlateWithResult();
}
private DelegateExecution prepareExecution() {
DelegateExecution delegateExecution = mock(DelegateExecution.class);
- when(delegateExecution.getProcessBusinessKey()).thenReturn("testBusinessKey");
+ when(delegateExecution.getProcessInstanceId()).thenReturn(PROCESS_INSTANCE_ID);
ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class);
when(delegateExecution.getProcessEngineServices()).thenReturn(processEngineServices);
RuntimeService runtimeService = mock(RuntimeService.class);
messageCorrelationBuilder = mock(MessageCorrelationBuilder.class);
when(runtimeService.createMessageCorrelation(any())).thenReturn(messageCorrelationBuilder);
- when(messageCorrelationBuilder.processInstanceBusinessKey(any())).thenReturn(messageCorrelationBuilder);
+ when(messageCorrelationBuilder.processInstanceId(any())).thenReturn(messageCorrelationBuilder);
return delegateExecution;
}