use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class BrokerStatusListenerTest method shouldSubmitErrorWhenDoneEventIsReceivedButToolingIsNull.
@Test
public void shouldSubmitErrorWhenDoneEventIsReceivedButToolingIsNull() {
// given
BrokerEvent event = new BrokerEvent().withRuntimeId(new RuntimeIdentityImpl(WORKSPACE_ID, null, null, null)).withStatus(BrokerStatus.DONE).withTooling(null);
// when
brokerStatusListener.onEvent(event);
// then
verify(brokersResult).error(any(InternalInfrastructureException.class));
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class BrokerStatusListenerTest method shouldAddResultWhenDoneEventIsReceivedAndToolingIsNotNull.
@Test
public void shouldAddResultWhenDoneEventIsReceivedAndToolingIsNotNull() throws Exception {
// given
BrokerEvent event = new BrokerEvent().withRuntimeId(new RuntimeIdentityImpl(WORKSPACE_ID, null, null, null)).withStatus(BrokerStatus.DONE).withTooling(emptyList());
// when
brokerStatusListener.onEvent(event);
// then
verify(brokersResult).setResult(emptyList());
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class EnvVarsConverterTest method setUp.
@BeforeMethod
public void setUp() {
testContainer = new Container();
PodSpec podSpec = new PodSpec();
podSpec.setContainers(singletonList(testContainer));
ObjectMeta podMeta = new ObjectMeta();
podMeta.setName("pod");
Pod pod = new Pod();
pod.setSpec(podSpec);
pod.setMetadata(podMeta);
Map<String, Pod> pods = new HashMap<>();
pods.put("pod", pod);
environment = KubernetesEnvironment.builder().setPods(pods).build();
machine = new InternalMachineConfig();
environment.setMachines(Collections.singletonMap(Names.machineName(podMeta, testContainer), machine));
identity = new RuntimeIdentityImpl("wsId", "blah", "bleh", "infraNamespace");
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class OpenShiftProjectFactoryTest method testUsernamePlaceholderInAnnotationsIsEvaluated.
@Test
public void testUsernamePlaceholderInAnnotationsIsEvaluated() throws InfrastructureException {
// given
projectFactory = spy(new OpenShiftProjectFactory("<userid>-che", true, true, true, NAMESPACE_LABELS, "try_placeholder_here=<username>", true, emptySet(), clientFactory, cheClientFactory, cheServerOpenshiftClientFactory, userManager, preferenceManager, pool, NO_OAUTH_IDENTITY_PROVIDER));
EnvironmentContext.getCurrent().setSubject(new SubjectImpl("jondoe", "123", null, false));
OpenShiftProject toReturnProject = mock(OpenShiftProject.class);
prepareProject(toReturnProject);
doReturn(toReturnProject).when(projectFactory).doCreateProjectAccess(any(), any());
// when
RuntimeIdentity identity = new RuntimeIdentityImpl("workspace123", null, USER_ID, "old-che");
OpenShiftProject project = projectFactory.getOrCreate(identity);
// then
assertEquals(toReturnProject, project);
verify(toReturnProject).prepare(eq(false), eq(false), any(), eq(Map.of("try_placeholder_here", "jondoe")));
}
use of org.eclipse.che.api.workspace.server.model.impl.RuntimeIdentityImpl in project devspaces-images by redhat-developer.
the class OpenShiftProjectFactoryTest method shouldRequireNamespacePriorExistenceIfDifferentFromDefaultAndUserDefinedIsNotAllowed.
@Test
public void shouldRequireNamespacePriorExistenceIfDifferentFromDefaultAndUserDefinedIsNotAllowed() throws Exception {
// There is only one scenario where this can happen. The workspace was created and started in
// some default namespace. Then server was reconfigured to use a different default namespace
// AND the namespace of the workspace was MANUALLY deleted in the cluster. In this case, we
// should NOT try to re-create the namespace because it would be created in a namespace that
// is not configured. We DO allow it to start if the namespace still exists though.
// given
projectFactory = spy(new OpenShiftProjectFactory("<userid>-che", true, true, true, NAMESPACE_LABELS, NAMESPACE_ANNOTATIONS, true, emptySet(), 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
RuntimeIdentity identity = new RuntimeIdentityImpl("workspace123", null, USER_ID, "old-default");
OpenShiftProject project = projectFactory.getOrCreate(identity);
// then
assertEquals(toReturnProject, project);
verify(toReturnProject).prepare(eq(false), eq(false), any(), any());
}
Aggregations