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);
}
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());
}
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);
}
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());
}
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>");
}
Aggregations