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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations