Search in sources :

Example 1 with KubernetesNamespaceMetaDto

use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto in project che-server by eclipse-che.

the class KubernetesNamespaceServiceTest method shouldReturnNamespaces.

@Test
public void shouldReturnNamespaces() throws Exception {
    KubernetesNamespaceMetaImpl namespaceMeta = new KubernetesNamespaceMetaImpl("ws-namespace", ImmutableMap.of("phase", "active", "default", "true"));
    when(namespaceFactory.list()).thenReturn(singletonList(namespaceMeta));
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/kubernetes/namespace");
    assertEquals(response.getStatusCode(), 200);
    List<KubernetesNamespaceMetaDto> namespaces = unwrapDtoList(response, KubernetesNamespaceMetaDto.class);
    assertEquals(namespaces.size(), 1);
    assertEquals(new KubernetesNamespaceMetaImpl(namespaces.get(0)), namespaceMeta);
    verify(namespaceFactory).list();
}
Also used : Response(io.restassured.response.Response) KubernetesNamespaceMetaDto(org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto) KubernetesNamespaceMetaImpl(org.eclipse.che.workspace.infrastructure.kubernetes.api.server.impls.KubernetesNamespaceMetaImpl) Test(org.testng.annotations.Test)

Example 2 with KubernetesNamespaceMetaDto

use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto in project che-server by eclipse-che.

the class KubernetesNamespaceServiceTest method shouldProvisionNamespace.

@Test
public void shouldProvisionNamespace() throws Exception {
    // given
    KubernetesNamespaceMetaImpl namespaceMeta = new KubernetesNamespaceMetaImpl("ws-namespace", ImmutableMap.of("phase", "active", "default", "true"));
    when(namespaceProvisioner.provision(any(NamespaceResolutionContext.class))).thenReturn(namespaceMeta);
    // when
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().post(SECURE_PATH + "/kubernetes/namespace/provision");
    // then
    assertEquals(response.getStatusCode(), 200);
    KubernetesNamespaceMetaDto actual = unwrapDto(response, KubernetesNamespaceMetaDto.class);
    assertEquals(actual.getName(), namespaceMeta.getName());
    assertEquals(actual.getAttributes(), namespaceMeta.getAttributes());
    verify(namespaceProvisioner).provision(any(NamespaceResolutionContext.class));
}
Also used : NamespaceResolutionContext(org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext) Response(io.restassured.response.Response) KubernetesNamespaceMetaDto(org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto) KubernetesNamespaceMetaImpl(org.eclipse.che.workspace.infrastructure.kubernetes.api.server.impls.KubernetesNamespaceMetaImpl) Test(org.testng.annotations.Test)

Example 3 with KubernetesNamespaceMetaDto

use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto in project devspaces-images by redhat-developer.

the class KubernetesNamespaceServiceTest method shouldReturnNamespaces.

@Test
public void shouldReturnNamespaces() throws Exception {
    KubernetesNamespaceMetaImpl namespaceMeta = new KubernetesNamespaceMetaImpl("ws-namespace", ImmutableMap.of("phase", "active", "default", "true"));
    when(namespaceFactory.list()).thenReturn(singletonList(namespaceMeta));
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/kubernetes/namespace");
    assertEquals(response.getStatusCode(), 200);
    List<KubernetesNamespaceMetaDto> namespaces = unwrapDtoList(response, KubernetesNamespaceMetaDto.class);
    assertEquals(namespaces.size(), 1);
    assertEquals(new KubernetesNamespaceMetaImpl(namespaces.get(0)), namespaceMeta);
    verify(namespaceFactory).list();
}
Also used : Response(io.restassured.response.Response) KubernetesNamespaceMetaDto(org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto) KubernetesNamespaceMetaImpl(org.eclipse.che.workspace.infrastructure.kubernetes.api.server.impls.KubernetesNamespaceMetaImpl) Test(org.testng.annotations.Test)

Example 4 with KubernetesNamespaceMetaDto

use of org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto in project devspaces-images by redhat-developer.

the class KubernetesNamespaceServiceTest method shouldProvisionNamespace.

@Test
public void shouldProvisionNamespace() throws Exception {
    // given
    KubernetesNamespaceMetaImpl namespaceMeta = new KubernetesNamespaceMetaImpl("ws-namespace", ImmutableMap.of("phase", "active", "default", "true"));
    when(namespaceProvisioner.provision(any(NamespaceResolutionContext.class))).thenReturn(namespaceMeta);
    // when
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().post(SECURE_PATH + "/kubernetes/namespace/provision");
    // then
    assertEquals(response.getStatusCode(), 200);
    KubernetesNamespaceMetaDto actual = unwrapDto(response, KubernetesNamespaceMetaDto.class);
    assertEquals(actual.getName(), namespaceMeta.getName());
    assertEquals(actual.getAttributes(), namespaceMeta.getAttributes());
    verify(namespaceProvisioner).provision(any(NamespaceResolutionContext.class));
}
Also used : NamespaceResolutionContext(org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext) Response(io.restassured.response.Response) KubernetesNamespaceMetaDto(org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto) KubernetesNamespaceMetaImpl(org.eclipse.che.workspace.infrastructure.kubernetes.api.server.impls.KubernetesNamespaceMetaImpl) Test(org.testng.annotations.Test)

Aggregations

Response (io.restassured.response.Response)4 KubernetesNamespaceMetaImpl (org.eclipse.che.workspace.infrastructure.kubernetes.api.server.impls.KubernetesNamespaceMetaImpl)4 KubernetesNamespaceMetaDto (org.eclipse.che.workspace.infrastructure.kubernetes.api.shared.dto.KubernetesNamespaceMetaDto)4 Test (org.testng.annotations.Test)4 NamespaceResolutionContext (org.eclipse.che.api.workspace.server.spi.NamespaceResolutionContext)2