Skip to content

Instantly share code, notes, and snippets.

@baldimir
Created July 11, 2018 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baldimir/7b4067d74d5fe32b0cb2360de14fd344 to your computer and use it in GitHub Desktop.
Save baldimir/7b4067d74d5fe32b0cb2360de14fd344 to your computer and use it in GitHub Desktop.
/*
* 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.modelcompiler;
import org.junit.Assert;
import org.junit.Test;
import org.kie.api.runtime.KieSession;
public class GetterSetterCaseTest extends BaseModelTest {
public GetterSetterCaseTest(RUN_TYPE testRunType) {
super(testRunType);
}
public static class TestFact {
private String aBcde;
public TestFact(String aBcde) {
this.aBcde = aBcde;
}
public String getaBcde() {
return aBcde;
}
public void setaBcde(String aBcde) {
this.aBcde = aBcde;
}
}
@Test
public void testGetterSetterCase() {
final String drl = "import " + TestFact.class.getCanonicalName() + ";\n" +
"import java.util.List;\n" +
"rule R1\n" +
"when \n" +
" TestFact(aBcde == \"test\")\n" +
"then end";
KieSession kieSession = getKieSession(drl);
kieSession.insert(new TestFact("test"));
Assert.assertEquals(1, kieSession.fireAllRules());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment