Skip to content

Commit

Permalink
[DROOLS-2757] throw an exception when trying to verify a not existing…
Browse files Browse the repository at this point in the history
… KieBase
  • Loading branch information
mariofusco committed Jul 25, 2018
1 parent c78d397 commit 3d61812
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public void verify(ResultsImpl messages) {

public void verify(String[] kBaseNames, ResultsImpl messages) {
for ( String modelName : kBaseNames ) {
buildKnowledgePackages( (KieBaseModelImpl) kBaseModels.get( modelName ), messages);
KieBaseModelImpl kieBaseModel = (KieBaseModelImpl) kBaseModels.get( modelName );
if ( kieBaseModel == null ) {
throw new RuntimeException( "Unknown KieBase. Cannot find a KieBase named: " + modelName );
}
buildKnowledgePackages( kieBaseModel, messages);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
* This is a sample class to launch a rule.
Expand Down Expand Up @@ -576,4 +577,21 @@ public void testHelloWorldWithSpace() throws Exception {

assertEquals( 1, count );
}

@Test
public void testVeyifyNotExistingKieBase() throws Exception {
// DROOLS-2757
KieServices ks = KieServices.Factory.get();

KieFileSystem kfs = ks.newKieFileSystem().write( "src/main/resources/r1.drl", createDrl( "R1" ) );
ks.newKieBuilder( kfs ).buildAll();

KieContainer kieContainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
try {
kieContainer.verify( "notexistingKB" );
fail("Verifying a not existing KieBase should throw a RuntimeException");
} catch (RuntimeException e) {
assertTrue( e.getMessage().contains( "notexistingKB" ) );
}
}
}

0 comments on commit 3d61812

Please sign in to comment.