private String generateResourceName(ResourceType type) { return "src/main/resources/file" + counter++ + "." + type.getDefaultExtension(); } }
String type = types[i].getDefaultExtension();
String type = types[i].getDefaultExtension();
String type = types[i].getDefaultExtension();
public static ReleaseId createKJarWithMultipleResources(String id, String[] resourceFiles, ResourceType[] types) throws IOException { KieServices ks = KieServices.Factory.get(); KieModuleModel kproj = ks.newKieModuleModel(); KieFileSystem kfs = ks.newKieFileSystem(); for (int i = 0; i < resourceFiles.length; i++) { Resource resource = ResourceFactory.newClassPathResource(resourceFiles[i]); String res = readResourceContent(resource); String type = types[i].getDefaultExtension(); kfs.write("src/main/resources/" + id.replaceAll("\\.", "/") + "/org/test/res" + i + "." + type, res); } KieBaseModel kBase1 = kproj.newKieBaseModel(id) .setEqualsBehavior(EqualityBehaviorOption.EQUALITY) .setEventProcessingMode(EventProcessingOption.STREAM); KieSessionModel ksession1 = kBase1 .newKieSessionModel(id + ".KSession1") .setType(KieSessionModel.KieSessionType.STATEFUL) .setClockType(ClockTypeOption.get("pseudo")); kfs.writeKModuleXML(kproj.toXML()); KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(); assertTrue(kieBuilder.getResults().getMessages().isEmpty()); KieModule kieModule = kieBuilder.getKieModule(); return kieModule.getReleaseId(); }
public static ReleaseId createKJarWithMultipleResources(String id, String[] resourceFiles, ResourceType[] types) throws IOException { KieServices ks = KieServices.Factory.get(); KieModuleModel kproj = ks.newKieModuleModel(); KieFileSystem kfs = ks.newKieFileSystem(); for (int i = 0; i < resourceFiles.length; i++) { Resource resource = ResourceFactory.newClassPathResource(resourceFiles[i]); String res = readResourceContent(resource); String type = types[i].getDefaultExtension(); kfs.write("src/main/resources/" + id.replaceAll("\\.", "/") + "/org/test/res" + i + "." + type, res); } KieBaseModel kBase1 = kproj.newKieBaseModel(id) .setEqualsBehavior(EqualityBehaviorOption.EQUALITY) .setEventProcessingMode(EventProcessingOption.STREAM); KieSessionModel ksession1 = kBase1 .newKieSessionModel(id + ".KSession1") .setType(KieSessionModel.KieSessionType.STATEFUL) .setClockType(ClockTypeOption.get("pseudo")); kfs.writeKModuleXML(kproj.toXML()); KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll(); assertTrue(kieBuilder.getResults().getMessages().isEmpty()); KieModule kieModule = kieBuilder.getKieModule(); return kieModule.getReleaseId(); }