Search in sources :

Example 1 with DekorateException

use of io.dekorate.DekorateException in project dekorate by dekorateio.

the class SerializationTest method shouldProduceMeaningFullErrorForSingleResource.

@Test
public void shouldProduceMeaningFullErrorForSingleResource() throws Exception {
    try (InputStream is = getClass().getClassLoader().getResourceAsStream("single-resource-with-errors.yml")) {
        KubernetesList list = Serialization.unmarshalAsList(is);
        fail();
    } catch (DekorateException e) {
        if (e.getCause() instanceof JsonProcessingException) {
            JsonProcessingException jpe = (JsonProcessingException) e.getCause();
            assertEquals(6, jpe.getLocation().getLineNr());
        } else {
            fail();
        }
    }
}
Also used : InputStream(java.io.InputStream) DekorateException(io.dekorate.DekorateException) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.jupiter.api.Test)

Example 2 with DekorateException

use of io.dekorate.DekorateException in project dekorate by dekorateio.

the class SerializationTest method shouldProduceMeaningFullErrorForMultipleResource.

@Test
public void shouldProduceMeaningFullErrorForMultipleResource() throws Exception {
    try (InputStream is = getClass().getClassLoader().getResourceAsStream("multiple-resources-with-errors.yml")) {
        KubernetesList list = Serialization.unmarshalAsList(is);
        fail();
    } catch (DekorateException e) {
        if (e.getCause() instanceof JsonProcessingException) {
            JsonProcessingException jpe = (JsonProcessingException) e.getCause();
            assertEquals(19, jpe.getLocation().getLineNr());
        } else {
            fail();
        }
    }
}
Also used : InputStream(java.io.InputStream) DekorateException(io.dekorate.DekorateException) KubernetesList(io.fabric8.kubernetes.api.model.KubernetesList) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.jupiter.api.Test)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 DekorateException (io.dekorate.DekorateException)2 KubernetesList (io.fabric8.kubernetes.api.model.KubernetesList)2 InputStream (java.io.InputStream)2 Test (org.junit.jupiter.api.Test)2