Codota Logo
RuleInput
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
BufferedReader b =
  • Codota IconInputStream in;new BufferedReader(new InputStreamReader(in))
  • Codota IconReader in;new BufferedReader(in)
  • Codota IconFile file;new BufferedReader(new FileReader(file))
  • Smart code suggestions by Codota
}
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

  • Finding current android device location
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getContentResolver (Context)
  • onRequestPermissionsResult (Fragment)
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JPanel (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now