Tabnine Logo
RuleInput
Code IndexAdd Tabnine to your IDE (free)

How to use
RuleInput
in
rocks.inspectit.server.diagnosis.engine.rule

Best Java code snippets using rocks.inspectit.server.diagnosis.engine.rule.RuleInput (Showing top 20 results out of 315)

origin: inspectIT/inspectIT

  @Test
  public void add() {
    RuleInput input = new RuleInput(Tags.tag("A", "input"));
    sessionContext.addExecution(rules.iterator().next(), input);
    assertThat(sessionContext.getExecutions().get(rules.iterator().next()), containsInAnyOrder(input));
  }
}
origin: inspectIT/inspectIT

@Test
public void multipleTagTypesSingleInput() throws RuleDefinitionException, SessionException {
  RuleDefinition ruleC = Rules.define(RuleC.class);
  Tag rootTag = Tags.rootTag("input");
  Tag tagA = Tags.tag("A", "A1", rootTag);
  Tag tagB = Tags.tag("B", "B1", tagA);
  RuleOutput outputB = new RuleOutput("RuleB", "B", Collections.<ConditionFailure> emptyList(), Collections.singletonList(tagB));
  when(outputStorage.findLatestResultsByTagType(Matchers.<Set<String>> anyObject())).thenReturn(Collections.singleton(outputB));
  List<RuleInput> ruleInputs = new ArrayList<>(session.collectInputs(ruleC, outputStorage));
  assertThat(ruleInputs, hasSize(1));
  assertThat(ruleInputs.get(0).getRoot(), equalTo(tagB));
  assertThat(ruleInputs.get(0).getUnraveled(), containsInAnyOrder(tagB, tagA));
}
origin: inspectIT/inspectIT

    throw new RuleExecutionException("If resultQuantity is MULTIPLE ensure that either an Array or a Collection is defined as return value", context);
  transformed.addAll(Tags.tags(getResultTag(), context.getRuleInput().getRoot(), values));
  break;
case SINGLE:
default:
  transformed.add(Tags.tag(getResultTag(), result, context.getRuleInput().getRoot()));
origin: inspectIT/inspectIT

@Test
public void shouldInjectValue() throws RuleExecutionException {
  // prepare
  when(input.getUnraveled()).thenReturn(Tags.tags("T1", null, "InjectedValue"));
  // execute
  new TagInjection("T1", RuleDummy.tagStringValueField()).execute(context);
  // verify
  assertThat(ruleImpl.tagStringValueField, is("InjectedValue"));
}
origin: inspectIT/inspectIT

@Test
public void singleTagTypeSingleInput() throws RuleDefinitionException, SessionException {
  RuleDefinition ruleB = Rules.define(RuleB.class);
  Tag rootTag = Tags.rootTag("input");
  Tag tagA = Tags.tag("A", "input", rootTag);
  RuleOutput outputA = new RuleOutput("RuleA", "A", Collections.<ConditionFailure> emptyList(), Collections.singletonList(tagA));
  when(outputStorage.findLatestResultsByTagType(Matchers.<Set<String>> anyObject())).thenReturn(Collections.singleton(outputA));
  List<RuleInput> ruleInputs = new ArrayList<>(session.collectInputs(ruleB, outputStorage));
  assertThat(ruleInputs, hasSize(1));
  assertThat(ruleInputs.get(0).getRoot(), equalTo(tagA));
}
origin: inspectIT/inspectIT

  @Test
  public void shouldInjectTag() throws RuleExecutionException {
    // prepare
    when(input.getUnraveled()).thenReturn(Tags.tags("T1", null, "InjectedValue"));
    // execute
    new TagInjection("T1", RuleDummy.tagAsTagField(), TagValue.InjectionStrategy.BY_TAG).execute(context);
    // verify
    assertThat(ruleImpl.tagAsTagField, is(Tags.tag("T1", "InjectedValue")));
  }
}
origin: inspectIT/inspectIT

@Test
public void filterOne() throws RuleDefinitionException, SessionException {
  RuleDefinition ruleB = Rules.define(RuleB.class);
  RuleInput inputA1 = new RuleInput(Tags.tag("A", "A1"));
  RuleInput inputA2 = new RuleInput(Tags.tag("A", "A2"));
  RuleInput inputA3 = new RuleInput(Tags.tag("A", "A3"));
  RuleInput inputB = new RuleInput(Tags.tag("B", "XY"));
  RuleInput inputC = new RuleInput(Tags.tag("C", "XY"));
  Collection<RuleInput> inputs = Arrays.asList(inputA1, inputA2, inputA3, inputB, inputC);
  Multimap<RuleDefinition, RuleInput> executions = ArrayListMultimap.create();
  executions.put(ruleB, inputA1);
  inputs = session.filterProcessedInputs(executions, ruleB, inputs);
  assertThat(inputs, containsInAnyOrder(inputA2, inputA3, inputB, inputC));
}
origin: inspectIT/inspectIT

  @Test(expectedExceptions = RuleDefinitionException.class)
  public void shouldFailDueToQuantityAndResultMismatch() throws RuleDefinitionException, RuleExecutionException {
    Tag rootTag = Tags.rootTag("Input");
    when(dummy.action()).thenReturn("Fail");
    when(this.input.getRoot()).thenReturn(rootTag);
    // Execute and fail. ActionMethod would expect array/collection as result from ruleImpl
    // implementation.
    // But receives "Fail" String
    new ActionMethod(RuleDummy.actionMethod(), "T2", Action.Quantity.MULTIPLE).execute(context);
  }
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 * 
 * @throws RuleExecutionException
 *             If tag injection fails.
 */
@Override
public Object determineValueToInject(ExecutionContext context) throws RuleExecutionException {
  // extract the required type form the unraveled list of input Tags
  for (Tag tag : context.getRuleInput().getUnraveled()) {
    if (tag.getType().equals(getType())) {
      return InjectionStrategy.BY_VALUE.equals(getInjectionStrategy()) ? tag.getValue() : tag;
    }
  }
  throw new RuleExecutionException("Unable to find Tag: " + getType() + " in RuleInput.", context);
}
origin: inspectIT/inspectIT

if (tags.size() == requiredInputTags.size()) {
  inputs.add(new RuleInput(leafTag, tags));
} else {
origin: inspectIT/inspectIT

@Test
public void shouldProduceSingleTagWithSingleObjectValue() throws Exception {
  // prepare Mocks
  Tag rootTag = Tags.rootTag("Input");
  Tag expectedResultTag = new Tag("T1", "oneResult", rootTag);
  when(dummy.action()).thenReturn("oneResult");
  when(input.getRoot()).thenReturn(rootTag);
  // Create TestMethod
  ActionMethod action = new ActionMethod(RuleDummy.actionMethod(), "T1", Action.Quantity.SINGLE);
  // execute
  Collection<Tag> result = action.execute(context);
  // verify
  assertThat(result, hasSize(1));
  assertThat(result, hasItem(expectedResultTag));
}
origin: inspectIT/inspectIT

@Test
public void filterTwo() throws RuleDefinitionException, SessionException {
  RuleDefinition ruleB = Rules.define(RuleB.class);
  RuleDefinition ruleA = Rules.define(RuleA.class);
  RuleInput inputA1 = new RuleInput(Tags.tag("A", "A1"));
  RuleInput inputA2 = new RuleInput(Tags.tag("A", "A2"));
  RuleInput inputA3 = new RuleInput(Tags.tag("A", "A3"));
  RuleInput inputB = new RuleInput(Tags.tag("B", "XY"));
  RuleInput inputC = new RuleInput(Tags.tag("C", "XY"));
  Collection<RuleInput> inputs = Arrays.asList(inputA1, inputA2, inputA3, inputB, inputC);
  Multimap<RuleDefinition, RuleInput> executions = ArrayListMultimap.create();
  executions.put(ruleA, inputA1);
  executions.put(ruleB, inputA2);
  executions.put(ruleB, inputA3);
  inputs = session.filterProcessedInputs(executions, ruleB, inputs);
  assertThat(inputs, containsInAnyOrder(inputA1, inputB, inputC));
}
origin: inspectIT/inspectIT

@Test
public void shouldProduceMultipleTagsFromSingleArray() throws Exception {
  Tag rootTag = Tags.rootTag("Input");
  // prepare Mocks
  when(dummy.action2()).thenReturn(new String[] { "one", "two", "three" });
  when(this.input.getRoot()).thenReturn(rootTag);
  // Create TestMethod
  ActionMethod action = new ActionMethod(RuleDummy.action2Method(), "T2", Action.Quantity.MULTIPLE);
  // execute
  Collection<Tag> result = action.execute(context);
  // verify
  Collection<Tag> tags = Tags.tags("T2", rootTag, "one", "two", "three");
  assertThat(result, containsInAnyOrder(tags.toArray()));
}
origin: inspectIT/inspectIT

@Test
public void singleTagTypeMultipleInputs() throws RuleDefinitionException, SessionException {
  RuleDefinition ruleB = Rules.define(RuleB.class);
  Tag rootTag = Tags.rootTag("input");
  Tag tagA1 = Tags.tag("A", "A1", rootTag);
  Tag tagA2 = Tags.tag("A", "A2", rootTag);
  Tag tagA3 = Tags.tag("A", "A3", rootTag);
  RuleOutput outputA = new RuleOutput("RuleA", "A", Collections.<ConditionFailure> emptyList(), Arrays.asList(tagA1, tagA2, tagA3));
  when(outputStorage.findLatestResultsByTagType(Matchers.<Set<String>> anyObject())).thenReturn(Collections.singleton(outputA));
  Collection<RuleInput> ruleInputs = session.collectInputs(ruleB, outputStorage);
  assertThat(ruleInputs, hasSize(3));
  assertThat(ruleInputs, containsInAnyOrder(new RuleInput(tagA1, Sets.newHashSet(tagA1)), new RuleInput(tagA2, Sets.newHashSet(tagA2)), new RuleInput(tagA3, Sets.newHashSet(tagA3))));
}
origin: inspectIT/inspectIT

@Test
public void shouldProduceMultipleTagsFromCollection() throws Exception {
  // prepare Mocks
  Tag rootTag = Tags.rootTag("Input");
  when(dummy.action2()).thenReturn(new String[] { "one", "two", "three" });
  when(this.input.getRoot()).thenReturn(rootTag);
  // Create TestMethod
  ActionMethod action = new ActionMethod(RuleDummy.action2Method(), "T2", Action.Quantity.MULTIPLE);
  // execute
  Collection<Tag> result = action.execute(context);
  // verify
  Collection<Tag> tags = Tags.tags("T2", rootTag, "one", "two", "three");
  assertThat(result, containsInAnyOrder(tags.toArray()));
}
origin: inspectIT/inspectIT

@Test
public void multipleTagTypesMultipleInputs1() throws RuleDefinitionException, SessionException {
  RuleDefinition ruleC = Rules.define(RuleC.class);
  Tag rootTag = Tags.rootTag("input");
  Tag tagA = Tags.tag("A", "A1", rootTag);
  Tag tagB1 = Tags.tag("B", "B1", tagA);
  Tag tagB2 = Tags.tag("B", "B2", tagA);
  RuleOutput outputB = new RuleOutput("RuleB", "B", Collections.<ConditionFailure> emptyList(), Arrays.asList(tagB1, tagB2));
  when(outputStorage.findLatestResultsByTagType(Matchers.<Set<String>> anyObject())).thenReturn(Collections.singleton(outputB));
  Collection<RuleInput> ruleInputs = session.collectInputs(ruleC, outputStorage);
  assertThat(ruleInputs, hasSize(2));
  assertThat(ruleInputs, containsInAnyOrder(new RuleInput(tagB1, Sets.newHashSet(tagA, tagB1)), new RuleInput(tagB2, Sets.newHashSet(tagA, tagB2))));
}
origin: inspectIT/inspectIT

@Test
public void shouldProduceSingleTagWithArrayValue() throws Exception {
  // prepare Mocks
  Tag rootTag = Tags.rootTag("Input");
  Tag expectedResultTag = new Tag("T1", new String[] { "one", "two", "three" }, rootTag);
  when(dummy.action()).thenReturn(new String[] { "one", "two", "three" });
  when(this.input.getRoot()).thenReturn(rootTag);
  // Create TestMethod
  ActionMethod action = new ActionMethod(RuleDummy.actionMethod(), "T1", Action.Quantity.SINGLE);
  // execute
  Collection<Tag> result = action.execute(context);
  // verify
  assertThat(result, hasSize(1));
  assertThat(result, containsInAnyOrder(expectedResultTag));
}
origin: inspectIT/inspectIT

  @Test
  public void filterAll() throws RuleDefinitionException, SessionException {
    RuleDefinition ruleB = Rules.define(RuleB.class);
    RuleDefinition ruleA = Rules.define(RuleA.class);
    RuleInput inputA1 = new RuleInput(Tags.tag("A", "A1"));
    RuleInput inputA2 = new RuleInput(Tags.tag("A", "A2"));
    RuleInput inputA3 = new RuleInput(Tags.tag("A", "A3"));
    RuleInput inputB = new RuleInput(Tags.tag("B", "XY"));
    RuleInput inputC = new RuleInput(Tags.tag("C", "XY"));
    Collection<RuleInput> inputs = Arrays.asList(inputA1, inputA2, inputA3, inputB, inputC);
    Multimap<RuleDefinition, RuleInput> executions = ArrayListMultimap.create();
    executions.put(ruleB, inputA1);
    executions.put(ruleB, inputA2);
    executions.put(ruleB, inputA3);
    executions.put(ruleB, inputB);
    executions.put(ruleB, inputC);
    inputs = session.filterProcessedInputs(executions, ruleB, inputs);
    assertThat(inputs, empty());
  }
}
origin: inspectIT/inspectIT

@Test
public void simpleRuleExecution() throws RuleDefinitionException, RuleExecutionException {
  RuleDefinition ruleDefinition = Rules.define(RuleA.class);
  String inputStr = "hallo";
  RuleInput input = new RuleInput(Tags.tag(Tags.ROOT_TAG, inputStr));
  RuleOutput output = ruleDefinition.execute(input, Collections.<String, Object> emptyMap());
  assertThat(output.getRuleName(), equalTo(ruleDefinition.getName()));
  assertThat(output.getTags(), hasSize(1));
  assertThat(output.getTags().iterator().next().getValue(), equalTo((Object) (inputStr + inputStr)));
}
origin: inspectIT/inspectIT

@Test
public void ruleWithSessionVariableExecution() throws RuleDefinitionException, RuleExecutionException {
  RuleDefinition ruleDefinition = Rules.define(RuleWithSessionVariable.class);
  String inputStr = "hallo";
  String sessionVar = "sessionVar";
  RuleInput input = new RuleInput(Tags.tag(Tags.ROOT_TAG, inputStr));
  RuleOutput output = ruleDefinition.execute(input, Collections.singletonMap(sessionVar, (Object) sessionVar));
  assertThat(output.getRuleName(), equalTo(ruleDefinition.getName()));
  assertThat(output.getTags(), hasSize(1));
  assertThat(output.getTags().iterator().next().getValue(), equalTo((Object) (inputStr + sessionVar)));
}
rocks.inspectit.server.diagnosis.engine.ruleRuleInput

Javadoc

Value object defining the input for a single rule execution.

Most used methods

  • <init>
    Constructor with unraveled collection.
  • getRoot
    Gets #root.
  • getUnraveled
    Gets #unraveled.

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • getApplicationContext (Context)
  • getSystemService (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Collectors (java.util.stream)
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now