use of org.kie.internal.builder.ResourceChangeSet in project drools by kiegroup.
the class ChangeSetBuilderTest method testModified.
@Test
public void testModified() {
String drl1 = "package org.drools\n" + "rule R1 when\n" + " $m : Message( message == \"Hello World\" )\n" + "then\n" + "end\n";
String drl2 = "package org.drools\n" + "rule R2 when\n" + " $m : Message( message == \"Hello World\" )\n" + "then\n" + "end\n";
String drl3 = "package org.drools\n" + "rule R3 when\n" + " $m : Message( message == \"Good bye World\" )\n" + "then\n" + "end\n";
InternalKieModule kieJar1 = createKieJar(drl1, drl2);
InternalKieModule kieJar2 = createKieJar(drl1, drl3);
KieJarChangeSet changes = ChangeSetBuilder.build(kieJar1, kieJar2);
String modifiedFile = (String) kieJar2.getFileNames().toArray()[1];
assertThat(changes.getChanges().size(), is(1));
ResourceChangeSet cs = changes.getChanges().get(modifiedFile);
assertThat(cs, not(nullValue()));
assertThat(cs.getChangeType(), is(ChangeType.UPDATED));
assertThat(cs.getChanges().size(), is(2));
assertThat(cs.getChanges().get(1), is(new ResourceChange(ChangeType.ADDED, Type.RULE, "R3")));
assertThat(cs.getChanges().get(0), is(new ResourceChange(ChangeType.REMOVED, Type.RULE, "R2")));
// ChangeSetBuilder builder = new ChangeSetBuilder();
// System.out.println( builder.toProperties( changes ) );
}
Aggregations