use of org.guvnor.ala.services.api.RuntimeQuery in project kie-wb-common by kiegroup.
the class RuntimeProvisioningServiceBackendImplTest method testExecuteQuery.
@Test
public void testExecuteQuery() {
RuntimeQuery query = mock(RuntimeQuery.class);
List<RuntimeQueryResultItem> values = mockList(RuntimeQueryResultItem.class, ELEMENTS_COUNT);
RuntimeQueryResultItemList list = new RuntimeQueryResultItemList(values);
when(runtimeProvisioningService.executeQuery(query)).thenReturn(list);
List<RuntimeQueryResultItem> result = runtimeProvisioningServiceBackend.executeQuery(query);
verify(runtimeProvisioningService, times(1)).executeQuery(query);
assertEquals(values, result);
}
use of org.guvnor.ala.services.api.RuntimeQuery in project kie-wb-common by kiegroup.
the class RestRuntimeProvisioningImplTest method testAPI.
@Test
public void testAPI() {
ProviderTypeList allProviderTypes = runtimeService.getProviderTypes(0, 10, "", true);
assertEquals(2, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfig() {
};
runtimeService.registerProvider(dockerProviderConfig);
ProviderList allProviders = runtimeService.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
Provider p = allProviders.getItems().get(0);
assertTrue(p instanceof DockerProvider);
assertNotNull(p.getId());
assertNotNull(p.getProviderType());
assertNotNull(p.getConfig());
DockerRuntimeConfig dockerRuntimeConfiguration = new DockerRuntimeConfig() {
@Override
public String getImage() {
return "kitematic/hello-world-nginx";
}
@Override
public String getPort() {
return "8080";
}
@Override
public boolean isPull() {
return true;
}
@Override
public ProviderId getProviderId() {
return p;
}
};
String newRuntime = runtimeService.newRuntime(dockerRuntimeConfiguration);
assertNotNull(newRuntime);
RuntimeList allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
RuntimeQuery query = RuntimeQueryBuilder.newInstance().withProviderId(p.getId()).build();
RuntimeQueryResultItemList queryResult = runtimeService.executeQuery(query);
assertEquals(1, queryResult.getItems().size());
assertEquals(RuntimeState.RUNNING, queryResult.getItems().get(0).getRuntimeStatus());
runtimeService.destroyRuntime(newRuntime, true);
allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
}
use of org.guvnor.ala.services.api.RuntimeQuery in project kie-wb-common by kiegroup.
the class RuntimeServiceImpl method getRuntimeItem.
@Override
public RuntimeListItem getRuntimeItem(final PipelineExecutionTraceKey pipelineExecutionTraceKey) {
checkNotNull("pipelineExecutionTraceKey", pipelineExecutionTraceKey);
final RuntimeQuery query = RuntimeQueryBuilder.newInstance().withPipelineExecutionId(pipelineExecutionTraceKey.getId()).build();
return buildRuntimeQueryResult(runtimeProvisioningService.executeQuery(query)).stream().findFirst().orElse(null);
}
use of org.guvnor.ala.services.api.RuntimeQuery in project kie-wb-common by kiegroup.
the class RuntimeServiceImpl method getRuntimeItem.
@Override
public RuntimeListItem getRuntimeItem(final RuntimeKey runtimeKey) {
checkNotNull("runtimeKey", runtimeKey);
final RuntimeQuery query = RuntimeQueryBuilder.newInstance().withRuntimeId(runtimeKey.getId()).build();
return buildRuntimeQueryResult(runtimeProvisioningService.executeQuery(query)).stream().findFirst().orElse(null);
}
use of org.guvnor.ala.services.api.RuntimeQuery in project kie-wb-common by kiegroup.
the class RuntimeServiceImpl method getRuntimeItems.
@Override
public Collection<RuntimeListItem> getRuntimeItems(final ProviderKey providerKey) {
checkNotNull("providerKey", providerKey);
final RuntimeQuery query = RuntimeQueryBuilder.newInstance().withProviderId(providerKey.getId()).build();
return buildRuntimeQueryResult(runtimeProvisioningService.executeQuery(query));
}
Aggregations