Skip to content

Commit

Permalink
[DROOLS-3389] Created scenario simulation runtime modules (#2325)
Browse files Browse the repository at this point in the history
* [DROOLS-3389] Created scenario simulation runner module

* [DROOLS-3389] Created scenario simulation runner module

* [DROOLS-3389] Updated to 7.22.0-SNAPSHOT
  • Loading branch information
danielezonca authored and manstis committed May 8, 2019
1 parent c5cad2f commit 8d6a727
Show file tree
Hide file tree
Showing 91 changed files with 7,896 additions and 0 deletions.
33 changes: 33 additions & 0 deletions drools-scenario-simulation/drools-scenario-simulation-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>drools-scenario-simulation</artifactId>
<groupId>org.drools</groupId>
<version>7.22.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>drools-scenario-simulation-api</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
</dependency>

<dependency>
<groupId>org.kie.soup</groupId>
<artifactId>kie-soup-project-datamodel-api</artifactId>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.drools.scenariosimulation.api.model;

import java.util.Objects;

/**
* Single element of a expression, i.e. in person.fullName.last each component is an ExpressionElement
*/
public class ExpressionElement {

private String step;

public ExpressionElement() {
}

public ExpressionElement(String step) {
this.step = step;
}

public String getStep() {
return step;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ExpressionElement that = (ExpressionElement) o;
return Objects.equals(getStep(), that.getStep());
}

@Override
public int hashCode() {
return Objects.hash(getStep());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.drools.scenariosimulation.api.model;

import java.util.Objects;

/**
* Identify an expression. It is defined by a name and a type
*/
public class ExpressionIdentifier {

private String name;
private FactMappingType type;

public enum NAME {
Description,
Expected,
Given,
Index,
Other;
}

public static ExpressionIdentifier INDEX = create(NAME.Index.name(), FactMappingType.OTHER);
public static ExpressionIdentifier DESCRIPTION = create(NAME.Description.name(), FactMappingType.OTHER);

public ExpressionIdentifier() {
}

public ExpressionIdentifier(String name, FactMappingType type) {
this.name = name;
this.type = type;
}

public String getName() {
return name;
}

public FactMappingType getType() {
return type;
}

public static ExpressionIdentifier create(String name, FactMappingType type) {
return new ExpressionIdentifier(name, type);
}

@Override
public String toString() {
return "ExpressionIdentifier{" +
"name='" + name + '\'' +
", type=" + type +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ExpressionIdentifier that = (ExpressionIdentifier) o;
return Objects.equals(name, that.name) &&
type == that.type;
}

@Override
public int hashCode() {
return Objects.hash(name, type);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.drools.scenariosimulation.api.model;

import java.util.Objects;

/**
* A fact is identified by its name and the canonical name of its class
*/
public class FactIdentifier {

private String name;
private String className;

public static FactIdentifier INDEX = create("#", Integer.class.getCanonicalName());
public static FactIdentifier DESCRIPTION = create("Scenario description", String.class.getCanonicalName());
public static FactIdentifier EMPTY = create("Empty", Void.class.getName());

public FactIdentifier() {
}

public FactIdentifier(String name, String className) {
this.name = name;
this.className = className;
}

public String getName() {
return name;
}

public String getClassName() {
return className;
}

public String getClassNameWithoutPackage() {
if (className.contains(".")) {
return className.substring(className.lastIndexOf(".") + 1);
} else {
return className;
}
}

public static FactIdentifier create(String name, String className) {
return new FactIdentifier(name, className);
}

@Override
public String toString() {
return "FactIdentifier{" +
"name='" + name + '\'' +
", className='" + className + '\'' +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FactIdentifier that = (FactIdentifier) o;
return Objects.equals(name, that.name) &&
Objects.equals(className, that.className);
}

@Override
public int hashCode() {
return Objects.hash(name, className);
}
}
Loading

0 comments on commit 8d6a727

Please sign in to comment.