Search in sources :

Example 1 with Promotion

use of org.drools.testcoverage.common.model.Promotion in project drools by kiegroup.

the class LogicalInsertionsSerializationTest method testSerializeAndDeserializeSession.

@Test
public void testSerializeAndDeserializeSession() throws Exception {
    KieSession ksession = session.getStateful();
    File tempFile = File.createTempFile(name.getMethodName(), null);
    ksession.fireAllRules();
    try (OutputStream fos = new FileOutputStream(tempFile)) {
        Marshaller marshaller = getServices().getMarshallers().newMarshaller(getKbase());
        marshaller.marshall(fos, ksession);
    }
    try (InputStream fis = new FileInputStream(tempFile)) {
        Marshaller marshaller = getServices().getMarshallers().newMarshaller(getKbase());
        marshaller.unmarshall(fis, ksession);
    }
    ksession.insert(new Promotion("Claire", "Scientist"));
    int firedRules = ksession.fireAllRules();
    Assertions.assertThat(firedRules).isEqualTo(1);
}
Also used : Marshaller(org.kie.api.marshalling.Marshaller) KieSession(org.kie.api.runtime.KieSession) Promotion(org.drools.testcoverage.common.model.Promotion) KieSessionTest(org.drools.testcoverage.common.KieSessionTest) Test(org.junit.Test)

Aggregations

KieSessionTest (org.drools.testcoverage.common.KieSessionTest)1 Promotion (org.drools.testcoverage.common.model.Promotion)1 Test (org.junit.Test)1 Marshaller (org.kie.api.marshalling.Marshaller)1 KieSession (org.kie.api.runtime.KieSession)1