/** * {@inheritDoc} */ @Override protected void processData(DefaultData defaultData, EntityManager entityManager) { InvocationSequenceData invocSequence = (InvocationSequenceData) defaultData; assignBusinessContext(invocSequence); }
@Test public void invalidInputData() { TimerData invalidInput = new TimerData(); processor.process(invalidInput, entityManager); verifyNoMoreInteractions(ciService); }
/** * Assigns the business context to the passed {@link InvocationSequenceData} instance. * * @param invocSequence * {@link InvocationSequenceData} instance to assign the business context for. */ private void assignBusinessContext(InvocationSequenceData invocSequence) { List<ApplicationDefinition> applicationDefinitions = configurationInterfaceService.getApplicationDefinitions(); ApplicationDefinition appDefinition = identify(invocSequence, applicationDefinitions); if (null == appDefinition) { appDefinition = ApplicationDefinition.DEFAULT_APPLICATION_DEFINITION; } ApplicationData application = businessContextRegistryService.registerApplication(appDefinition); invocSequence.setApplicationId(application.getId()); BusinessTransactionDefinition businessTxDefinition = identify(invocSequence, appDefinition.getBusinessTransactionDefinitions()); String businessTxName = businessTxDefinition.determineBusinessTransactionName(invocSequence, cachedDataService); BusinessTransactionData businessTransaction = businessContextRegistryService.registerBusinessTransaction(application, businessTxDefinition, businessTxName); invocSequence.setBusinessTransactionId(businessTransaction.getId()); }
@Test public void businessContextChanged() throws InterruptedException { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "node"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); processor.onApplicationEvent(event); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_1.getId())); }
@Test public void matchEmptyApplication() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression_2); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application_empty.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_unknown.getId())); }
@Test public void match() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_2.getId())); }
@Test public void matchDefaultBT() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "root"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression_2); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_unknown.getId())); }
@Test public void matchDefaultAppAndBT() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(false); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression_2); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application_unknown.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_unknown.getId())); }
@Test public void matchWithSearchInTrace() { StringMatchingExpression stringMatchingExpression = new StringMatchingExpression(PatternMatchingType.CONTAINS, "multiple"); stringMatchingExpression.setStringValueSource(stringValueSource); stringMatchingExpression.setSearchNodeInTrace(true); stringMatchingExpression.setMaxSearchDepth(2); StringMatchingExpression stringMatchingExpression_2 = new StringMatchingExpression(PatternMatchingType.CONTAINS, "nothing"); stringMatchingExpression_2.setStringValueSource(stringValueSource); stringMatchingExpression_2.setSearchNodeInTrace(false); applicationDefinition.setMatchingRuleExpression(stringMatchingExpression); applicationDefinition_empty.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_1.setMatchingRuleExpression(stringMatchingExpression_2); businessTxDefinition_2.setMatchingRuleExpression(stringMatchingExpression); processor.process(root, entityManager); assertThat(root.getApplicationId(), equalTo(application.getId())); assertThat(root.getBusinessTransactionId(), equalTo(businessTx_2.getId())); }