Search in sources :

Example 16 with KieServerRegistry

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);
}
Also used : KieServerRegistry(org.kie.server.services.api.KieServerRegistry) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 17 with KieServerRegistry

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);
        }
    });
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) Description(org.hamcrest.Description) ProcessInstanceQueryFilterSpec(org.kie.server.api.model.definition.ProcessInstanceQueryFilterSpec) TaskQueryFilterSpec(org.kie.server.api.model.definition.TaskQueryFilterSpec) QueryFilterSpec(org.kie.server.api.model.definition.QueryFilterSpec) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) ReflectionEquals(org.mockito.internal.matchers.apachecommons.ReflectionEquals) Test(org.junit.Test)

Example 18 with KieServerRegistry

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());
}
Also used : KieServerRegistry(org.kie.server.services.api.KieServerRegistry) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 19 with KieServerRegistry

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);
}
Also used : KieServerController(org.kie.server.controller.api.KieServerController) KieServerSetup(org.kie.server.controller.api.model.KieServerSetup) ServerTemplate(org.kie.server.controller.api.model.spec.ServerTemplate) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) ServerTemplateList(org.kie.server.controller.api.model.spec.ServerTemplateList) KieServerInfo(org.kie.server.api.model.KieServerInfo) ServerInstanceKeyList(org.kie.server.controller.api.model.runtime.ServerInstanceKeyList) DefaultRestControllerImpl(org.kie.server.services.impl.controller.DefaultRestControllerImpl) KieServerRegistryImpl(org.kie.server.services.impl.KieServerRegistryImpl) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 20 with KieServerRegistry

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;
}
Also used : RulesExecutionService(org.kie.server.services.drools.RulesExecutionService) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) ArrayList(java.util.ArrayList)

Aggregations

KieServerRegistry (org.kie.server.services.api.KieServerRegistry)28 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)13 HashSet (java.util.HashSet)5 DefinitionService (org.jbpm.services.api.DefinitionService)4 RuntimeDataService (org.jbpm.services.api.RuntimeDataService)4 UserTaskService (org.jbpm.services.api.UserTaskService)4 ProcessInstanceQueryFilterSpecBuilder (org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder)4 QueryFilterSpecBuilder (org.kie.server.api.util.QueryFilterSpecBuilder)4 TaskQueryFilterSpecBuilder (org.kie.server.api.util.TaskQueryFilterSpecBuilder)4 KieServerRegistryImpl (org.kie.server.services.impl.KieServerRegistryImpl)4 HashMap (java.util.HashMap)3 List (java.util.List)3 FormManagerService (org.jbpm.kie.services.impl.FormManagerService)3 ProcessService (org.jbpm.services.api.ProcessService)3 QueryService (org.jbpm.services.api.query.QueryService)3 Map (java.util.Map)2 Set (java.util.Set)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2