use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class MarshallerHelperTest method testUnmarshallWithoutContainerWithExtraClasses.
@Test
public void testUnmarshallWithoutContainerWithExtraClasses() {
KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class);
Set<Class<?>> extraClasses = new HashSet<>();
extraClasses.add(TestExtraClass.class);
Mockito.when(kieServerRegistryMock.getExtraClasses()).thenReturn(extraClasses);
MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock);
TestExtraClass expectedExtraClass = new TestExtraClass();
expectedExtraClass.setBla("hallo");
String marshalledTEC = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<test-extra-class>" + "<bla>hallo</bla>" + "</test-extra-class>";
TestExtraClass unmarshalledTEC = helper.unmarshal(marshalledTEC, MarshallingFormat.JAXB.toString(), TestExtraClass.class);
assertEquals(expectedExtraClass, unmarshalledTEC);
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class MarshallerHelperTest method testUnmarshallWithoutContainer.
@Test
public void testUnmarshallWithoutContainer() {
KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class);
MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock);
QueryFilterSpec expectedQueryFilterSpec = new QueryFilterSpecBuilder().get();
String marshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>";
QueryFilterSpec unmarshalledQFS = helper.unmarshal(marshalledQFS, MarshallingFormat.JAXB.toString(), QueryFilterSpec.class);
// QueryFilterSpec does not implement equals method, so using Mockito ReflectionEquals.
assertThat(expectedQueryFilterSpec, new BaseMatcher<QueryFilterSpec>() {
@Override
public void describeTo(Description description) {
}
@Override
public boolean matches(Object item) {
return new ReflectionEquals(unmarshalledQFS).matches(item);
}
});
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class MarshallerHelperTest method testMarshallWithoutContainerWithExtraClasses.
@Test
public void testMarshallWithoutContainerWithExtraClasses() {
KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class);
Set<Class<?>> extraClasses = new HashSet<>();
extraClasses.add(TestExtraClass.class);
Mockito.when(kieServerRegistryMock.getExtraClasses()).thenReturn(extraClasses);
MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock);
TestExtraClass extraClass = new TestExtraClass();
extraClass.setBla("hallo");
String marshalledQFS = helper.marshal(MarshallingFormat.JAXB.toString(), extraClass);
String expectedMarshalledTEC = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<test-extra-class>" + "<bla>hallo</bla>" + "</test-extra-class>";
assertThat(marshalledQFS, CompareMatcher.isIdenticalTo(expectedMarshalledTEC).ignoreWhitespace());
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class KieControllerValidationIntegrationTest method testGoodRegistered.
@Test
// Added to UnstableOnJenkinsPrBuilder to avoid random failures/timeouts on Jenkins builds
@Category({ UnstableOnJenkinsPrBuilder.class })
public void testGoodRegistered() throws Exception {
final String SERVER_TEMPLATE_ID = "test.mode.ok";
final String SERVER_NAME = "server-name";
KieServerEnvironment.setServerId(SERVER_TEMPLATE_ID);
ServerTemplate serverTemplate = buildServerTemplate(SERVER_TEMPLATE_ID, SERVER_NAME, null, KieServerMode.DEVELOPMENT, Collections.singletonList(Capability.PROCESS.name()));
controllerClient.saveServerTemplate(serverTemplate);
ServerTemplateList instanceList = controllerClient.listServerTemplates();
assertEquals(1, instanceList.getServerTemplates().length);
// Register kie server in controller.
KieServerInfo kieServerInfo = new KieServerInfo(SERVER_TEMPLATE_ID, "1.0.0");
kieServerInfo.setLocation("http://127.0.0.1:20000");
kieServerInfo.setMode(KieServerMode.DEVELOPMENT);
kieServerInfo.setCapabilities(Collections.singletonList(KieServerConstants.CAPABILITY_BPM));
kieServerInfo.setName(SERVER_NAME);
KieServerRegistry registry = new KieServerRegistryImpl();
registry.registerStateRepository(dummyKieServerStateRepository);
KieServerController controller = new DefaultRestControllerImpl(registry);
KieServerSetup setup = controller.connect(kieServerInfo);
Assert.assertTrue(setup.hasNoErrors());
// Check that kie server is registered.
ServerInstanceKeyList list = controllerClient.getServerInstances(SERVER_TEMPLATE_ID);
// Sometimes the controller healthcheck deletes server instance sooner than we retrieve it back, in such case register the instance again
if (list == null || list.getServerInstanceKeys() == null || list.getServerInstanceKeys().length == 0) {
setup = controller.connect(kieServerInfo);
Assert.assertTrue(setup.hasNoErrors());
list = controllerClient.getServerInstances(SERVER_TEMPLATE_ID);
}
assertNotNull(list.getServerInstanceKeys());
assertEquals(1, list.getServerInstanceKeys().length);
// clear up
controller.disconnect(kieServerInfo);
controllerClient.deleteServerTemplate(SERVER_TEMPLATE_ID);
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class CustomDroolsKieServerApplicationComponentsService method getAppComponents.
@Override
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
// skip calls from other than owning extension
if (!OWNER_EXTENSION.equals(extension)) {
return Collections.emptyList();
}
RulesExecutionService rulesExecutionService = null;
KieServerRegistry context = null;
for (Object object : services) {
if (RulesExecutionService.class.isAssignableFrom(object.getClass())) {
rulesExecutionService = (RulesExecutionService) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
}
}
List<Object> components = new ArrayList<Object>();
if (SupportedTransports.REST.equals(type)) {
components.add(new CustomResource(rulesExecutionService, context));
}
return components;
}
Aggregations