Search in sources :

Example 21 with DevfileFormatException

use of org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException in project devspaces-images by redhat-developer.

the class KubernetesComponentValidator method validateComponent.

@Override
public void validateComponent(Component component, FileContentProvider contentProvider) throws DevfileFormatException {
    try {
        List<HasMetadata> selectedObjects = validateSelector(component, contentProvider);
        validateEntrypointSelector(component, selectedObjects);
    } catch (Exception e) {
        throw new DevfileFormatException(format("Failed to validate content reference of component '%s' of type '%s': %s", getIdentifiableComponentName(component), component.getType(), e.getMessage()), e);
    }
}
Also used : HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) DevfileFormatException(org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException) DevfileException(org.eclipse.che.api.workspace.server.devfile.exception.DevfileException) IOException(java.io.IOException) ValidationException(org.eclipse.che.api.core.ValidationException) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) DevfileFormatException(org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException)

Example 22 with DevfileFormatException

use of org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException in project devspaces-images by redhat-developer.

the class WorkspaceManagerTest method shouldFailTocreateWorkspaceUsingInconsistentDevfile.

@Test(expectedExceptions = ValidationException.class, expectedExceptionsMessageRegExp = "boom")
public void shouldFailTocreateWorkspaceUsingInconsistentDevfile() throws Exception {
    // given
    doThrow(new DevfileFormatException("boom")).when(devfileIntegrityValidator).validateContentReferences(any(), any());
    Devfile devfile = mock(Devfile.class);
    // when
    workspaceManager.createWorkspace(devfile, "ns", emptyMap(), null);
// then exception is thrown
}
Also used : DevfileFormatException(org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException) Devfile(org.eclipse.che.api.core.model.workspace.devfile.Devfile) Test(org.testng.annotations.Test)

Aggregations

DevfileFormatException (org.eclipse.che.api.workspace.server.devfile.exception.DevfileFormatException)22 IOException (java.io.IOException)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 BadRequestException (jakarta.ws.rs.BadRequestException)4 WebApplicationException (jakarta.ws.rs.WebApplicationException)4 ValidationException (org.eclipse.che.api.core.ValidationException)4 Component (org.eclipse.che.api.core.model.workspace.devfile.Component)4 Devfile (org.eclipse.che.api.core.model.workspace.devfile.Devfile)4 DevfileException (org.eclipse.che.api.workspace.server.devfile.exception.DevfileException)4 Test (org.testng.annotations.Test)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 Container (io.fabric8.kubernetes.api.model.Container)2 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)2 JsonReader (jakarta.json.JsonReader)2 StringReader (java.io.StringReader)2 String.format (java.lang.String.format)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2