Search in sources :

Example 6 with KieServerRegistry

use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.

the class MarshallerHelperTest method testJsonUnmarshallNotNull.

@Test
public void testJsonUnmarshallNotNull() throws JSONException {
    KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class);
    Set<Class<?>> extraClasses = new HashSet<>();
    // simulate server conditions
    extraClasses.add(Date.class);
    extraClasses.add(org.kie.server.api.model.type.JaxbByteArray.class);
    Mockito.when(kieServerRegistryMock.getExtraClasses()).thenReturn(extraClasses);
    MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock);
    JSONAssert.assertEquals("{\"order-asc\" : false}", helper.marshal("application/json ; fields = not_null ", new QueryFilterSpecBuilder().get()), true);
    // test reset
    JSONAssert.assertEquals("{\"order-by\" : null, \"order-asc\" : false, \"query-params\" : null, \"result-column-mapping\" : null, \"order-by-clause\" : null}", helper.marshal("application/json", new QueryFilterSpecBuilder().get()), true);
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with KieServerRegistry

use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.

the class MarshallerHelperTest method testMarshallWithoutContainer.

@Test
public void testMarshallWithoutContainer() {
    KieServerRegistry kieServerRegistryMock = Mockito.mock(KieServerRegistry.class);
    MarshallerHelper helper = new MarshallerHelper(kieServerRegistryMock);
    QueryFilterSpec queryFilterSpec = new QueryFilterSpecBuilder().get();
    String marshalledQFS = helper.marshal(MarshallingFormat.JAXB.toString(), queryFilterSpec);
    String expectedMarshalledQFS = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<query-filter-spec>" + "<order-asc>false</order-asc>" + "</query-filter-spec>";
    assertThat(marshalledQFS, CompareMatcher.isIdenticalTo(expectedMarshalledQFS).ignoreWhitespace());
}
Also used : ProcessInstanceQueryFilterSpecBuilder(org.kie.server.api.util.ProcessInstanceQueryFilterSpecBuilder) QueryFilterSpecBuilder(org.kie.server.api.util.QueryFilterSpecBuilder) TaskQueryFilterSpecBuilder(org.kie.server.api.util.TaskQueryFilterSpecBuilder) 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) Test(org.junit.Test)

Example 8 with KieServerRegistry

use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.

the class KeepLatestContainerOnlyPolicyTest method testDisposeOldContainer.

@Test
public void testDisposeOldContainer() {
    KieServerRegistry kieServerRegistry = new KieServerRegistryImpl();
    KieContainerInstanceImpl kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_ONE, KieContainerStatus.STARTED, kieContainerOne);
    kieServerRegistry.registerContainer(CONTAINER_ONE, kieContainerInstance);
    kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_TWO, KieContainerStatus.STARTED, kieContainerTwo);
    kieServerRegistry.registerContainer(CONTAINER_TWO, kieContainerInstance);
    KeepLatestContainerOnlyPolicy policy = new KeepLatestContainerOnlyPolicy();
    policy.apply(kieServerRegistry, kieServer);
    verify(kieServer).disposeContainer(CONTAINER_ONE);
}
Also used : KieServerRegistry(org.kie.server.services.api.KieServerRegistry) KieContainerInstanceImpl(org.kie.server.services.impl.KieContainerInstanceImpl) KieServerRegistryImpl(org.kie.server.services.impl.KieServerRegistryImpl) Test(org.junit.Test)

Example 9 with KieServerRegistry

use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.

the class KeepLatestContainerOnlyPolicyTest method testDoNotDisposeNewerCreatedContainer.

@Test
public void testDoNotDisposeNewerCreatedContainer() {
    KieServerRegistry kieServerRegistry = new KieServerRegistryImpl();
    KieContainerInstanceImpl kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_ONE, KieContainerStatus.STARTED, kieContainerOne);
    kieServerRegistry.registerContainer(CONTAINER_ONE, kieContainerInstance);
    kieContainerInstance = new KieContainerInstanceImpl(CONTAINER_TWO, KieContainerStatus.CREATING, kieContainerTwo);
    kieServerRegistry.registerContainer(CONTAINER_TWO, kieContainerInstance);
    KeepLatestContainerOnlyPolicy policy = new KeepLatestContainerOnlyPolicy();
    policy.apply(kieServerRegistry, kieServer);
    verify(kieServer, never()).disposeContainer(anyString());
}
Also used : KieServerRegistry(org.kie.server.services.api.KieServerRegistry) KieContainerInstanceImpl(org.kie.server.services.impl.KieContainerInstanceImpl) KieServerRegistryImpl(org.kie.server.services.impl.KieServerRegistryImpl) Test(org.junit.Test)

Example 10 with KieServerRegistry

use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.

the class FormRendererBaseTest method testGenerateDefaultForm.

@Test
public void testGenerateDefaultForm() {
    DefinitionService definitionService = mock(DefinitionService.class);
    UserTaskService userTaskService = mock(UserTaskService.class);
    FormManagerService formManagerService = mock(FormManagerService.class);
    CaseRuntimeDataService caseRuntimeDataService = mock(CaseRuntimeDataService.class);
    KieServerRegistry registry = mock(KieServerRegistry.class);
    ProcessDefinition processDefinition = mock(ProcessDefinition.class);
    when(processDefinition.getId()).thenReturn("testprocess");
    when(processDefinition.getName()).thenReturn("Test Process");
    FormRendererBase rendererBase = new FormRendererBase(definitionService, userTaskService, formManagerService, caseRuntimeDataService, registry);
    when(registry.getContainerId(any(), any())).thenReturn("test");
    when(definitionService.getProcessDefinition(eq("test"), eq("test-process"))).thenReturn(processDefinition);
    String result = rendererBase.getProcessRenderedForm("patternfly", "test", "test-process");
    logger.debug("Form content is '{}'", result);
    assertThat(result).isNotNull().isNotEmpty();
    // it has the patternfly (default renderer) css
    assertThat(result).contains("/files/patternfly/css/patternfly.min.css\" rel=\"stylesheet\">");
    assertThat(result).contains("/files/patternfly/css/patternfly-additions.min.css\" rel=\"stylesheet\">");
    // it has required js files
    assertThat(result).contains("/files/patternfly/js/jquery.min.js\"></script>");
    assertThat(result).contains("/files/patternfly/js/patternfly.min.js\"></script>");
    assertThat(result).contains("/files/js/kieserver-ui.js\"></script>");
    // it has the form header
    assertThat(result).contains("<h3 class=\"panel-title\">Default form - Test Process</h3>");
}
Also used : DefinitionService(org.jbpm.services.api.DefinitionService) CaseRuntimeDataService(org.jbpm.casemgmt.api.CaseRuntimeDataService) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) UserTaskService(org.jbpm.services.api.UserTaskService) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition) FormManagerService(org.jbpm.kie.services.impl.FormManagerService) Test(org.junit.Test)

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