use of org.eclipse.che.api.core.model.workspace.Warning in project che-server by eclipse-che.
the class WorkspaceRuntimesTest method mockContext.
private RuntimeContext mockContext(RuntimeIdentity identity) throws ValidationException, InfrastructureException {
RuntimeContext context = mock(RuntimeContext.class);
InternalEnvironment internalEnvironment = mock(InternalEnvironment.class);
lenient().doReturn(internalEnvironment).when(testEnvFactory).create(any(Environment.class));
lenient().doReturn(context).when(infrastructure).prepare(eq(identity), eq(internalEnvironment));
lenient().when(context.getInfrastructure()).thenReturn(infrastructure);
lenient().when(context.getIdentity()).thenReturn(identity);
lenient().when(context.getRuntime()).thenReturn(new TestInternalRuntime(context));
lenient().when(context.getEnvironment()).thenReturn(internalEnvironment);
List<Warning> warnings = new ArrayList<>();
warnings.add(createWarning());
lenient().when(internalEnvironment.getWarnings()).thenReturn(warnings);
return context;
}
use of org.eclipse.che.api.core.model.workspace.Warning in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRelatedCommands.
@Test
public void shouldFillInWarningIfChePluginDoesNotHaveAnyContainersButThereAreRelatedCommands() throws Exception {
// given
ChePlugin chePlugin = createChePlugin("somePublisher/custom-name/0.0.3");
String pluginRef = chePlugin.getId();
CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom");
pluginCommand.getAttributes().put("plugin", pluginRef);
internalEnvironment.getCommands().add(pluginCommand);
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
List<Warning> envWarnings = internalEnvironment.getWarnings();
assertEquals(envWarnings.size(), 1);
Warning warning = envWarnings.get(0);
assertEquals(warning.getCode(), Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITHOUT_CONTAINERS_WARNING_CODE);
assertEquals(warning.getMessage(), "There are configured commands for plugin 'somePublisher/custom-name/0.0.3' that doesn't have any containers");
}
use of org.eclipse.che.api.core.model.workspace.Warning in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelatedCommands.
@Test
public void shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelatedCommands() throws Exception {
// given
ChePlugin chePlugin = createChePlugin(createContainer(), createContainer());
String pluginRef = chePlugin.getId();
CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom");
pluginCommand.getAttributes().put("plugin", pluginRef);
internalEnvironment.getCommands().add(pluginCommand);
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
List<Warning> envWarnings = internalEnvironment.getWarnings();
assertEquals(envWarnings.size(), 1);
Warning warning = envWarnings.get(0);
assertEquals(warning.getCode(), Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITH_MULTIPLY_CONTAINERS_WARNING_CODE);
assertEquals(warning.getMessage(), "There are configured commands for plugin '" + pluginRef + "' that has multiply containers. Commands will be configured to be run in first container");
}
use of org.eclipse.che.api.core.model.workspace.Warning in project devspaces-images by redhat-developer.
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.core.model.workspace.Warning in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelatedCommands.
@Test
public void shouldFillInWarningIfChePluginHasMultiplyContainersButThereAreRelatedCommands() throws Exception {
// given
ChePlugin chePlugin = createChePlugin(createContainer(), createContainer());
String pluginRef = chePlugin.getId();
CommandImpl pluginCommand = new CommandImpl("test-command", "echo Hello World!", "custom");
pluginCommand.getAttributes().put("plugin", pluginRef);
internalEnvironment.getCommands().add(pluginCommand);
// when
applier.apply(runtimeIdentity, internalEnvironment, singletonList(chePlugin));
// then
List<Warning> envWarnings = internalEnvironment.getWarnings();
assertEquals(envWarnings.size(), 1);
Warning warning = envWarnings.get(0);
assertEquals(warning.getCode(), Warnings.COMMAND_IS_CONFIGURED_IN_PLUGIN_WITH_MULTIPLY_CONTAINERS_WARNING_CODE);
assertEquals(warning.getMessage(), "There are configured commands for plugin '" + pluginRef + "' that has multiply containers. Commands will be configured to be run in first container");
}
Aggregations