use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class KubernetesNamespaceFactoryTest method shouldPrepareWorkspaceServiceAccountIfItIsConfiguredAndNamespaceIsNotPredefined.
@Test
public void shouldPrepareWorkspaceServiceAccountIfItIsConfiguredAndNamespaceIsNotPredefined() throws Exception {
// given
var serviceAccountCfg = spy(new WorkspaceServiceAccountConfigurator("serviceAccount", "", clientFactory));
namespaceFactory = spy(new KubernetesNamespaceFactory("<username>-che", true, true, true, NAMESPACE_LABELS, NAMESPACE_ANNOTATIONS, Set.of(serviceAccountCfg), clientFactory, cheClientFactory, userManager, preferenceManager, pool));
KubernetesNamespace toReturnNamespace = mock(KubernetesNamespace.class);
prepareNamespace(toReturnNamespace);
when(toReturnNamespace.getName()).thenReturn("workspace123");
doReturn(toReturnNamespace).when(namespaceFactory).doCreateNamespaceAccess(any(), any());
KubernetesWorkspaceServiceAccount serviceAccount = mock(KubernetesWorkspaceServiceAccount.class);
doReturn(serviceAccount).when(serviceAccountCfg).doCreateServiceAccount(any(), any());
// when
RuntimeIdentity identity = new RuntimeIdentityImpl("workspace123", null, USER_ID, "workspace123");
namespaceFactory.getOrCreate(identity);
// then
verify(serviceAccountCfg).doCreateServiceAccount("workspace123", "workspace123");
verify(serviceAccount).prepare();
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class BrokerStatusListenerTest method shouldNotCallAddResultWhenValidationFails.
@Test
public void shouldNotCallAddResultWhenValidationFails() throws Exception {
// given
doThrow(new ValidationException("test")).when(validator).validatePluginNames(anyList());
BrokerEvent event = new BrokerEvent().withRuntimeId(new RuntimeIdentityImpl(WORKSPACE_ID, null, null, null)).withStatus(BrokerStatus.DONE).withTooling(emptyList());
// when
brokerStatusListener.onEvent(event);
// then
verify(brokersResult, never()).setResult(anyList());
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class BrokerStatusListenerTest method shouldSubmitErrorWhenDoneEventIsReceivedButToolingIsValidationFails.
@Test
public void shouldSubmitErrorWhenDoneEventIsReceivedButToolingIsValidationFails() throws Exception {
// given
doThrow(new ValidationException("test")).when(validator).validatePluginNames(anyList());
BrokerEvent event = new BrokerEvent().withRuntimeId(new RuntimeIdentityImpl(WORKSPACE_ID, null, null, null)).withStatus(BrokerStatus.DONE).withTooling(emptyList());
// when
brokerStatusListener.onEvent(event);
// then
verify(brokersResult).error(any(ValidationException.class));
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class BrokerStatusListenerTest method shouldSubmitErrorWhenFailedEventIsReceived.
@Test
public void shouldSubmitErrorWhenFailedEventIsReceived() {
// given
BrokerEvent event = new BrokerEvent().withRuntimeId(new RuntimeIdentityImpl(WORKSPACE_ID, null, null, null)).withStatus(BrokerStatus.FAILED).withError("error");
// when
brokerStatusListener.onEvent(event);
// then
verify(brokersResult).error(any(InfrastructureException.class));
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class OpenShiftProjectFactoryTest method shouldNotCreatePreferencesConfigmapIfExist.
@Test
public void shouldNotCreatePreferencesConfigmapIfExist() throws Exception {
// given
projectFactory = spy(new OpenShiftProjectFactory("<userid>-che", true, true, true, NAMESPACE_LABELS, NAMESPACE_ANNOTATIONS, true, Set.of(new PreferencesConfigMapConfigurator(clientFactory)), clientFactory, cheClientFactory, cheServerOpenshiftClientFactory, userManager, preferenceManager, pool, NO_OAUTH_IDENTITY_PROVIDER));
OpenShiftProject toReturnProject = mock(OpenShiftProject.class);
prepareProject(toReturnProject);
doReturn(toReturnProject).when(projectFactory).doCreateProjectAccess(any(), any());
when(toReturnProject.getName()).thenReturn("namespace123");
NonNamespaceOperation namespaceOperation = mock(NonNamespaceOperation.class);
MixedOperation mixedOperation = mock(MixedOperation.class);
when(osClient.configMaps()).thenReturn(mixedOperation);
when(mixedOperation.inNamespace(anyString())).thenReturn(namespaceOperation);
Resource<ConfigMap> cmResource = mock(Resource.class);
when(namespaceOperation.withName(PREFERENCES_CONFIGMAP_NAME)).thenReturn(cmResource);
when(cmResource.get()).thenReturn(mock(ConfigMap.class));
// when
RuntimeIdentity identity = new RuntimeIdentityImpl("workspace123", null, USER_ID, "workspace123");
projectFactory.getOrCreate(identity);
// then
verify(namespaceOperation, never()).create(any());
}
Aggregations