use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project che-server by eclipse-che.
the class GitConfigProvisionerTest method testShouldExpectWarningWhenPreferenceManagerThrowsServerException.
@Test
public void testShouldExpectWarningWhenPreferenceManagerThrowsServerException() throws Exception {
when(preferenceManager.find(eq("id"), eq("theia-user-preferences"))).thenThrow(new ServerException("message"));
gitConfigProvisioner.provision(k8sEnv, runtimeIdentity);
verifyNoMoreInteractions(runtimeIdentity);
List<Warning> warnings = k8sEnv.getWarnings();
assertEquals(warnings.size(), 1);
Warning actualWarning = warnings.get(0);
String warnMsg = format(Warnings.EXCEPTION_IN_USER_MANAGEMENT_DURING_GIT_PROVISION_MESSAGE_FMT, "message");
Warning expectedWarning = new WarningImpl(Warnings.EXCEPTION_IN_USER_MANAGEMENT_DURING_GIT_PROVISION_WARNING_CODE, warnMsg);
assertEquals(expectedWarning, actualWarning);
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project che-server by eclipse-che.
the class RestartPolicyRewriterTest method rewritesRestartPolicyWhenItsDifferentWithDefaultOne.
@Test
public void rewritesRestartPolicyWhenItsDifferentWithDefaultOne() throws Exception {
Pod pod = newPod(TEST_POD_NAME, ALWAYS_RESTART_POLICY);
PodData podData = new PodData(pod.getSpec(), pod.getMetadata());
when(k8sEnv.getPodsData()).thenReturn(singletonMap(TEST_POD_NAME, podData));
restartPolicyRewriter.provision(k8sEnv, runtimeIdentity);
assertEquals(pod.getSpec().getRestartPolicy(), DEFAULT_RESTART_POLICY);
verifyWarnings(new WarningImpl(RESTART_POLICY_SET_TO_NEVER_WARNING_CODE, format("Restart policy '%s' for pod '%s' is rewritten with %s", ALWAYS_RESTART_POLICY, TEST_POD_NAME, DEFAULT_RESTART_POLICY)));
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project che-server by eclipse-che.
the class SecureServerExposerFactoryProviderTest method shouldAddWarningIfSecureServerConfiguredInEnvironmentWasNotFound.
@Test
public void shouldAddWarningIfSecureServerConfiguredInEnvironmentWasNotFound() {
// given
SecureServerExposerFactoryProvider<KubernetesEnvironment> factoryProvider = new SecureServerExposerFactoryProvider<>(EXPOSER1, factories);
kubernetesEnvironment.setAttributes(ImmutableMap.of(SECURE_EXPOSER_IMPL_PROPERTY, NON_EXISTING_EXPOSER));
WarningImpl expectedWarning = new WarningImpl(UNKNOWN_SECURE_SERVER_EXPOSER_CONFIGURED_IN_WS_WARNING_CODE, format(UNKNOWN_EXPOSER_ERROR_TEMPLATE, NON_EXISTING_EXPOSER, String.join(", ", factories.keySet())));
SecureServerExposerFactory<KubernetesEnvironment> factory = factoryProvider.get(kubernetesEnvironment);
// then
assertSame(factory, secureServerExposer1);
assertEquals(kubernetesEnvironment.getWarnings().size(), 1);
assertEquals(kubernetesEnvironment.getWarnings().get(0), expectedWarning);
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project che-server by eclipse-che.
the class DeploymentMetadataProvisionerTest method shouldAddWarningIfLabelAttributeInInvalidFormat.
@Test
public void shouldAddWarningIfLabelAttributeInInvalidFormat() throws NotFoundException, ServerException, InfrastructureException {
// given
when(workspace.getAttributes()).thenReturn(ImmutableMap.of(WS_DEPLOYMENT_LABELS_ATTR_NAME, "L1~V1"));
when(workspaceManager.getWorkspace(eq(WS_ID))).thenReturn(workspace);
Deployment deployment = newDeployment();
doReturn(ImmutableMap.of(DEPLOYMENT_NAME, deployment)).when(k8sEnv).getDeploymentsCopy();
// when
provisioner.provision(k8sEnv, identity);
// then
ArgumentCaptor<WarningImpl> argumentCaptor = ArgumentCaptor.forClass(WarningImpl.class);
verify(k8sEnv).addWarning(argumentCaptor.capture());
assertEquals(argumentCaptor.getAllValues().size(), 1);
assertEquals(argumentCaptor.getValue(), new WarningImpl(NOT_ABLE_TO_PROVISION_WORKSPACE_DEPLOYMENT_LABELS_OR_ANNOTATIONS, "Not able to provision workspace " + WS_ID + " deployment labels or annotations because of invalid configuration. Reason: 'Chunk [L1~V1] is not a valid entry'"));
}
use of org.eclipse.che.api.workspace.server.model.impl.WarningImpl in project che-server by eclipse-che.
the class DeploymentMetadataProvisionerTest method shouldAddWarningIfAnnotationAttributeInInvalidFormat.
@Test
public void shouldAddWarningIfAnnotationAttributeInInvalidFormat() throws NotFoundException, ServerException, InfrastructureException {
// given
when(workspace.getAttributes()).thenReturn(ImmutableMap.of(WS_DEPLOYMENT_ANNOTATIONS_ATTR_NAME, "A1~V1"));
when(workspaceManager.getWorkspace(eq(WS_ID))).thenReturn(workspace);
Deployment deployment = newDeployment();
doReturn(ImmutableMap.of(DEPLOYMENT_NAME, deployment)).when(k8sEnv).getDeploymentsCopy();
// when
provisioner.provision(k8sEnv, identity);
// then
ArgumentCaptor<WarningImpl> argumentCaptor = ArgumentCaptor.forClass(WarningImpl.class);
verify(k8sEnv).addWarning(argumentCaptor.capture());
assertEquals(argumentCaptor.getAllValues().size(), 1);
assertEquals(argumentCaptor.getValue(), new WarningImpl(NOT_ABLE_TO_PROVISION_WORKSPACE_DEPLOYMENT_LABELS_OR_ANNOTATIONS, "Not able to provision workspace " + WS_ID + " deployment labels or annotations because of invalid configuration. Reason: 'Chunk [A1~V1] is not a valid entry'"));
}
Aggregations