### Question:
RegisterForPnfReadyEvent implements JavaDelegate { @Override public void execute(DelegateExecution execution) { try { String pnfName = getPnfName(execution); fillExecution(execution, pnfName); RuntimeService runtimeService = execution.getProcessEngineServices().getRuntimeService(); dmaapClient.registerForUpdate(pnfName, () -> runtimeService.createMessageCorrelation("WorkflowMessage") .processInstanceId(execution.getProcessInstanceId()).correlateWithResult()); } catch (BBObjectNotFoundException e) { LOGGER.error(ERROR_MESSAGE_PNF_NOT_FOUND); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, ERROR_MESSAGE_PNF_NOT_FOUND); } } @Autowired  RegisterForPnfReadyEvent(DmaapClient dmaapClient, ExtractPojosForBB extractPojosForBB,
            ExceptionBuilder exceptionBuilder,
            @Value("${aai.pnfEntryNotificationTimeout}") String pnfEntryNotificationTimeout); @Override void execute(DelegateExecution execution);  }### Answer:
@Test public void shouldRegisterForDmaapClient() throws BBObjectNotFoundException { testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock, PNF_ENTRY_NOTIFICATION_TIMEOUT); Pnf pnf = new Pnf(); pnf.setPnfName(PNF_NAME); when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(pnf); testedObject.execute(delegateExecution); verify(delegateExecution).setVariable(ExecutionVariableNames.PNF_CORRELATION_ID, PNF_NAME); verify(delegateExecution).setVariable(ExecutionVariableNames.TIMEOUT_FOR_NOTIFICATION, PNF_ENTRY_NOTIFICATION_TIMEOUT); checkIfInformConsumerThreadIsRunProperly(dmaapClientTest); }
@Test public void pnfNotFoundInBBexecution_WorkflowExIsThrown() throws BBObjectNotFoundException { testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock, PNF_ENTRY_NOTIFICATION_TIMEOUT); when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)) .thenThrow(BBObjectNotFoundException.class); testedObject.execute(delegateExecution); verify(exceptionBuilderMock).buildAndThrowWorkflowException(delegateExecution, 7000, "pnf resource not found in buildingBlockExecution while registering to dmaap listener"); }
@Test public void pnfNameIsNull_WorkflowExIsThrown() throws BBObjectNotFoundException { testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock, PNF_ENTRY_NOTIFICATION_TIMEOUT); when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(new Pnf()); testedObject.execute(delegateExecution); verify(exceptionBuilderMock).buildAndThrowWorkflowException(delegateExecution, 7000, "pnf name is not set"); }
@Test public void pnfEventNotificationTimeoutNotSet_WorkflowExIsThrown() throws BBObjectNotFoundException { testedObject = new RegisterForPnfReadyEvent(dmaapClientTest, extractPojosForBBMock, exceptionBuilderMock, null); when(extractPojosForBBMock.extractByKey(buildingBlockExecution, ResourceKey.PNF)).thenReturn(new Pnf()); testedObject.execute(delegateExecution); verify(exceptionBuilderMock).buildAndThrowWorkflowException(delegateExecution, 7000, "pnfEntryNotificationTimeout value not defined"); }