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

How to use
DMNRuntimeUtil
in
org.kie.dmn.core.util

Best Java code snippets using org.kie.dmn.core.util.DMNRuntimeUtil (Showing top 20 results out of 315)

origin: org.kie/kie-dmn-core

@Test
public void testModelById() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass() );
  final DMNModel dmnModel = runtime.getModelById("https://github.com/kiegroup/kie-dmn/itemdef", "_simple-item-def" );
  assertThat( dmnModel, notNullValue() );
  assertThat( DMNRuntimeUtil.formatMessages( dmnModel.getMessages() ), dmnModel.hasErrors(), is( false ) );
}
origin: org.kie/kie-dmn-core

@Test
public void testImportDS() {
  // DROOLS-2768 DMN Decision Service encapsulate Decision which imports a Decision Service
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("DecisionService20180718.dmn", this.getClass(), "ImportDecisionService20180718.dmn");
  final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0ff3708a-c861-4a96-b85c-7b882f18b7a1", "Import Decision Service 20180718");
  assertThat(dmnModel, notNullValue());
  assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
  testImportDS_testEvaluateAll(runtime, dmnModel);
  testImportDS_testEvaluateDS(runtime, dmnModel);
}
origin: org.kie/kie-dmn-core

public static KieContainer getKieContainerIgnoringErrors(ReleaseId releaseId,
                             Resource... resources) {
  KieServices ks = KieServices.Factory.get();
  createAndDeployJarIgnoringErrors(ks, releaseId, resources);
  return ks.newKieContainer(releaseId);
}
origin: org.kie/kie-dmn-core

@Test
public void testWrongTypeRefForDRGElement() {
  // DROOLS-2917 DMN resolveTypeRef returning null in BKM causes NPE during KieContainer compilation
  final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongTypeRefForDRGElement.dmn", this.getClass());
  DMNRuntimeUtil.formatMessages(messages);
  assertThat(messages.isEmpty(), is(false));
  assertThat(messages.stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.TYPE_DEF_NOT_FOUND)), is(true));
  assertThat(messages.stream().anyMatch(m -> m.getSourceId().equals("_561d31ba-a34b-4cf3-b9a4-537e21ce1013")), is(true));
  assertThat(messages.stream().anyMatch(m -> m.getSourceId().equals("_45fa8674-f4f0-4c06-b2fd-52bbd17d8550")), is(true));
}
origin: org.kie/kie-dmn-core

@Test
public void testFiltering() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Person_filtering_by_age.dmn", getClass() );
  runtime.addListener( DMNRuntimeUtil.createListener() );
  final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_e215ed7a-701b-4c53-b8df-4b4d23d5fe32", "Person filtering by age" );
  assertThat( dmnModel, notNullValue() );
  assertThat( DMNRuntimeUtil.formatMessages( dmnModel.getMessages() ), dmnModel.hasErrors(), is( false ) );
  final DMNContext context = DMNFactory.newContext();
  context.set( "Min Age", 50 );
  final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context );
  assertThat( DMNRuntimeUtil.formatMessages( dmnResult.getMessages() ), ((List)dmnResult.getContext().get("Filtering")).size(), is( 2 ) );
}
origin: org.kie/kie-dmn-core

@Test
public void testCompilationThrowsNPE() {
  try {
    DMNRuntimeUtil.createRuntime( "compilationThrowsNPE.dmn", this.getClass() );
  } catch (final IllegalStateException ex) {
    assertThat(ex.getMessage(), Matchers.containsString("Unable to compile DMN model for the resource"));
  }
}
origin: org.kie/kie-dmn-core

private void testDSForTypeCheck_runAllDecisionsWithWrongTypes(final DMNRuntime runtime, final DMNModel dmnModel) {
  final DMNContext context = DMNFactory.newContext();
  context.set("Person name", BigDecimal.valueOf(21));
  context.set("Person age", "John");
  final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
  LOG.debug("{}", dmnResult);
  dmnResult.getDecisionResults().forEach(x -> LOG.debug("{}", x));
  assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(true));
}
origin: org.kie/kie-dmn-core

@Test
public void testImport3Levels() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("L3_Do_say_hello.dmn",
                                          this.getClass(),
                                          "Do_say_hello_with_2_bkms.dmn",
    runtime.addListener(DMNRuntimeUtil.createListener());
                          "Saying hello 2 bkms");
  assertThat(importedModel, notNullValue());
  assertThat(DMNRuntimeUtil.formatMessages(importedModel.getMessages()), importedModel.hasErrors(), is(false));
  assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
  assertThat(DMNRuntimeUtil.formatMessages(dmnModelL3.getMessages()), dmnModelL3.hasErrors(), is(false));
  assertThat(DMNRuntimeUtil.formatMessages(evaluateAll.getMessages()), evaluateAll.hasErrors(), is(false));
origin: org.kie/kie-dmn-core

@Test
public void testImportTransitiveBaseModel() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("Sayhello1ID1D.dmn",
                                          this.getClass(),
                                          "ModelB.dmn",
                                          "ModelB2.dmn",
                                          "ModelC.dmn");
  getAndAssertModelNoErrors(runtime, "http://www.trisotech.com/dmn/definitions/_ae5b3c17-1ac3-4e1d-b4f9-2cf861aec6d9", "Say hello 1ID1D");
}
origin: org.kie/kie-dmn-core

@Test
public void testEventListeners() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("car_damage_responsibility.dmn", this.getClass() );
  runtime.addListener( DMNRuntimeUtil.createListener() );
origin: org.kie/kie-dmn-core

@Test
public void testErrorMessages() {
  final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("car_damage_responsibility2.dmn", this.getClass());
  assertThat(messages.isEmpty(), is(false));
}
origin: org.kie/kie-dmn-core

public static DMNRuntime createRuntime(final Class testClass) {
  final KieServices ks = KieServices.Factory.get();
  final KieContainer kieContainer = KieHelper.getKieContainer(
  ks.newReleaseId("org.kie", "dmn-test-"+UUID.randomUUID(), "1.0"));
  final DMNRuntime runtime = typeSafeGetKieRuntime(kieContainer);
  Assert.assertNotNull(runtime);
  return runtime;
}
origin: org.kie/kie-dmn-core

public static List<DMNMessage> createExpectingDMNMessages(final String resourceName, final Class testClass) {
  final KieServices ks = KieServices.Factory.get();
  final KieContainer kieContainer = getKieContainerIgnoringErrors(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"),
                                  ks.getResources().newClassPathResource(resourceName, testClass));
  Results verify = kieContainer.verify();
  List<Message> kie_messages = verify.getMessages();
  LOG.debug("{}", kie_messages);
  List<DMNMessage> dmnMessages = kie_messages.stream()
                        .filter(DMNMessage.class::isInstance)
                        .map(DMNMessage.class::cast)
                        .collect(Collectors.toList());
  assertThat(dmnMessages.isEmpty(), is(false));
  return dmnMessages;
}
origin: org.kie/kie-dmn-core

public static KieModule createAndDeployJarIgnoringErrors(KieServices ks,
                             ReleaseId releaseId,
                             Resource... resources) {
  byte[] jar = createJarIgnoringErrors(ks, releaseId, resources);
  KieModule km = KieHelper.deployJarIntoRepository(ks, jar);
  return km;
}
origin: org.kie/kie-dmn-core

@Test
public void testNowFunction() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("today_function_test.dmn", getClass() );
  runtime.addListener( DMNRuntimeUtil.createListener() );
  final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_4ad80959-5fd8-46b7-8c9a-ab2fa58cb5b4", "When is it" );
  assertThat( dmnModel, notNullValue() );
  assertThat( DMNRuntimeUtil.formatMessages( dmnModel.getMessages() ), dmnModel.hasErrors(), is( false ) );
  final DMNContext context = DMNFactory.newContext();
  context.set( "The date", LocalDate.of(2017, 1, 12 ) );
  final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context );
  assertThat( DMNRuntimeUtil.formatMessages( dmnResult.getMessages() ), dmnResult.getContext().get("When is it"), is( "It is in the past" ) );
}
origin: org.kie/kie-dmn-core

@Test
public void testDecisionTableWithCalculatedResult() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntime( "calculation1.dmn", this.getClass() );
  checkDecisionTableWithCalculatedResult(runtime);
}
origin: org.kie/kie-dmn-core

  public static DMNModel getAndAssertModelNoErrors(final DMNRuntime runtime, final String namespace, final String modelName) {
    DMNModel dmnModel = runtime.getModel(namespace, modelName);
    assertThat(dmnModel, notNullValue());
    assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
    return dmnModel;
  }
}
origin: org.kie/kie-dmn-core

@Test
public void testInvalidFunction() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources( "InvalidFunction.dmn", this.getClass() );
  final DMNModel model = runtime.getModel( "http://www.trisotech.com/definitions/_84453b71-5d23-479f-9481-5196d92bacae", "0003-iteration-augmented" );
  assertThat( model, notNullValue() );
  final DMNContext context = DMNFactory.newContext();
  context.set( "Loans", new HashMap<>() );
  final DMNResult result = runtime.evaluateAll(model, context);
  final List<DMNDecisionResult> decisionResults = result.getDecisionResults();
  FEELStringMarshaller.INSTANCE.marshall( Arrays.asList(decisionResults.get(0).getResult(), decisionResults.get(1).getResult()) );
}
origin: org.kie/kie-dmn-core

@Test
public void testWrongConstraintsInItemDefinition() {
  // DROOLS-1503
  final List<DMNMessage> messages = DMNRuntimeUtil.createExpectingDMNMessages("WrongConstraintsInItemDefinition.dmn", this.getClass());
  assertThat(DMNRuntimeUtil.formatMessages(messages), messages.size(), is(3));
  assertThat(messages.get(0).getSourceReference(), is(instanceOf(ItemDefinition.class)));
  assertThat(messages.get(0).getMessageType(), is(DMNMessageType.ERR_COMPILING_FEEL));
  assertThat(messages.get(1).getSourceId(), is("_e794c655-4fdf-45d1-b7b7-d990df513f92"));
  assertThat(messages.get(1).getMessageType(), is(DMNMessageType.ERR_COMPILING_FEEL));
  
  // The DecisionTable does not define typeRef for the single OutputClause, but neither the enclosing Decision define typeRef for its variable
  assertThat(messages.get(2).getSourceId(), is("_31911de7-e184-411c-99d1-f33977971270"));
  assertThat(messages.get(2).getMessageType(), is(DMNMessageType.MISSING_TYPE_REF));
}

origin: org.kie/kie-dmn-core

@Test
public void testContextEventListeners() {
  final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("context_listener.dmn", this.getClass() );
  runtime.addListener( DMNRuntimeUtil.createListener() );
org.kie.dmn.core.utilDMNRuntimeUtil

Javadoc

A type-check safe runtime creation helper.

Most used methods

  • createRuntime
  • createRuntimeWithAdditionalResources
  • formatMessages
  • createAndDeployJarIgnoringErrors
  • createExpectingDMNMessages
  • createJarIgnoringErrors
  • createListener
  • getKieContainerIgnoringErrors
  • typeSafeGetKieRuntime

Popular in Java

  • Finding current android device location
  • getSharedPreferences (Context)
  • setRequestProperty (URLConnection)
  • setScale (BigDecimal)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • 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
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Best plugins for Eclipse
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