Search in sources :

Example 1 with RuntimeQuery

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);
}
Also used : RuntimeQueryResultItemList(org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList) RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery) RuntimeQueryResultItem(org.guvnor.ala.services.api.RuntimeQueryResultItem) Test(org.junit.Test)

Example 2 with RuntimeQuery

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());
}
Also used : RuntimeQueryResultItemList(org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList) ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) RuntimeList(org.guvnor.ala.services.api.itemlist.RuntimeList) RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery) DockerRuntimeConfig(org.guvnor.ala.docker.config.DockerRuntimeConfig) DockerProviderConfig(org.guvnor.ala.docker.config.DockerProviderConfig) ProviderTypeList(org.guvnor.ala.services.api.itemlist.ProviderTypeList) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) Provider(org.guvnor.ala.runtime.providers.Provider) Test(org.junit.Test)

Example 3 with RuntimeQuery

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);
}
Also used : RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery)

Example 4 with RuntimeQuery

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);
}
Also used : RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery)

Example 5 with RuntimeQuery

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));
}
Also used : RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery)

Aggregations

RuntimeQuery (org.guvnor.ala.services.api.RuntimeQuery)5 RuntimeQueryResultItemList (org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList)2 Test (org.junit.Test)2 DockerProviderConfig (org.guvnor.ala.docker.config.DockerProviderConfig)1 DockerRuntimeConfig (org.guvnor.ala.docker.config.DockerRuntimeConfig)1 DockerProvider (org.guvnor.ala.docker.model.DockerProvider)1 Provider (org.guvnor.ala.runtime.providers.Provider)1 RuntimeQueryResultItem (org.guvnor.ala.services.api.RuntimeQueryResultItem)1 ProviderList (org.guvnor.ala.services.api.itemlist.ProviderList)1 ProviderTypeList (org.guvnor.ala.services.api.itemlist.ProviderTypeList)1 RuntimeList (org.guvnor.ala.services.api.itemlist.RuntimeList)1