Search in sources :

Example 1 with AggregatedException

use of com.github.havardh.javaflow.exceptions.AggregatedException in project javaflow by havardh.

the class ClassGetterNamingVerifierTest method shouldFailForModelWithGetterWithNonMatchingType.

@Test
public void shouldFailForModelWithGetterWithNonMatchingType() {
    Class aClass = ClassBuilder.classBuilder().withPackageName("com.github.havardh.models").withName("Class").withField(FieldBuilder.fieldBuilder().withName("someField").withType(PRIMITIVE_INT).build()).withGetter(MethodBuilder.methodBuilder().withName("getSomeField").withType(PRIMITIVE_DOUBLE).build()).build();
    AggregatedException exception = assertThrows(AggregatedException.class, () -> verifier.verify(singletonList(aClass)));
    assertThat(exception.getExceptions(), hasSize(1));
}
Also used : Class(com.github.havardh.javaflow.ast.Class) AggregatedException(com.github.havardh.javaflow.exceptions.AggregatedException) Test(org.junit.jupiter.api.Test)

Example 2 with AggregatedException

use of com.github.havardh.javaflow.exceptions.AggregatedException in project javaflow by havardh.

the class ClassGetterNamingVerifierTest method shouldFailAndReportMultipleFieldsPerClass.

@Test
public void shouldFailAndReportMultipleFieldsPerClass() {
    Class aClass = ClassBuilder.classBuilder().withPackageName("com.github.havardh.models").withName("Class").withField(FieldBuilder.fieldBuilder().withName("fieldOne").withType(PRIMITIVE_INT).build()).withField(FieldBuilder.fieldBuilder().withName("fieldTwo").withType(PRIMITIVE_INT).build()).withGetter(MethodBuilder.methodBuilder().withName("getFieldOnes").withType(PRIMITIVE_INT).build()).withGetter(MethodBuilder.methodBuilder().withName("getFieldTwos").withType(PRIMITIVE_INT).build()).build();
    AggregatedException exception = assertThrows(AggregatedException.class, () -> verifier.verify(singletonList(aClass)));
    assertThat(exception.getExceptions(), hasSize(2));
}
Also used : Class(com.github.havardh.javaflow.ast.Class) AggregatedException(com.github.havardh.javaflow.exceptions.AggregatedException) Test(org.junit.jupiter.api.Test)

Example 3 with AggregatedException

use of com.github.havardh.javaflow.exceptions.AggregatedException in project javaflow by havardh.

the class ClassGetterNamingVerifierTest method shouldFailForModelWithGetterWithNonMatchingName.

@Test
public void shouldFailForModelWithGetterWithNonMatchingName() {
    Class aClass = ClassBuilder.classBuilder().withPackageName("com.github.havardh.models").withName("Class").withField(FieldBuilder.fieldBuilder().withName("someField").withType(PRIMITIVE_INT).build()).withGetter(MethodBuilder.methodBuilder().withName("getSomeFields").withType(PRIMITIVE_INT).build()).build();
    AggregatedException exception = assertThrows(AggregatedException.class, () -> verifier.verify(singletonList(aClass)));
    assertThat(exception.getExceptions(), hasSize(1));
}
Also used : Class(com.github.havardh.javaflow.ast.Class) AggregatedException(com.github.havardh.javaflow.exceptions.AggregatedException) Test(org.junit.jupiter.api.Test)

Example 4 with AggregatedException

use of com.github.havardh.javaflow.exceptions.AggregatedException in project javaflow by havardh.

the class ClassGetterNamingVerifierTest method shouldFailForModelWithoutGetters.

@Test
public void shouldFailForModelWithoutGetters() {
    Class aClass = ClassBuilder.classBuilder().withPackageName("com.github.havardh.models").withName("Class").withField(FieldBuilder.fieldBuilder().withName("someField").withType(PRIMITIVE_INT).build()).build();
    AggregatedException exception = assertThrows(AggregatedException.class, () -> verifier.verify(singletonList(aClass)));
    assertThat(exception.getExceptions(), hasSize(1));
}
Also used : Class(com.github.havardh.javaflow.ast.Class) AggregatedException(com.github.havardh.javaflow.exceptions.AggregatedException) Test(org.junit.jupiter.api.Test)

Example 5 with AggregatedException

use of com.github.havardh.javaflow.exceptions.AggregatedException in project javaflow by havardh.

the class ClassGetterNamingVerifierTest method shouldFailAndReportOnMultipleErroneousClasses.

@Test
public void shouldFailAndReportOnMultipleErroneousClasses() {
    Class aClass = ClassBuilder.classBuilder().withPackageName("com.github.havardh.models").withName("aClass").withField(FieldBuilder.fieldBuilder().withName("fieldOne").withType(PRIMITIVE_INT).build()).build();
    Class bClass = ClassBuilder.classBuilder().withPackageName("com.github.havardh.models").withName("bClass").withField(FieldBuilder.fieldBuilder().withName("fieldOne").withType(PRIMITIVE_INT).build()).build();
    AggregatedException exception = assertThrows(AggregatedException.class, () -> verifier.verify(asList(aClass, bClass)));
    assertThat(exception.getExceptions(), hasSize(2));
}
Also used : Class(com.github.havardh.javaflow.ast.Class) AggregatedException(com.github.havardh.javaflow.exceptions.AggregatedException) Test(org.junit.jupiter.api.Test)

Aggregations

Class (com.github.havardh.javaflow.ast.Class)5 AggregatedException (com.github.havardh.javaflow.exceptions.AggregatedException)5 Test (org.junit.jupiter.api.Test)5