use of com.github.havardh.javaflow.ast.Class in project javaflow by havardh.
the class ClassGetterNamingVerifierTest method shouldPassForModelWithMatchingGetters.
@Test
public void shouldPassForModelWithMatchingGetters() {
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_INT).build()).build();
verifier.verify(singletonList(aClass));
}
use of com.github.havardh.javaflow.ast.Class 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.ast.Class 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.ast.Class 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.ast.Class in project javaflow by havardh.
the class MemberFieldsPresentVerifierTest method shouldPassForBuiltInTypes.
@Test
public void shouldPassForBuiltInTypes() {
Class aClass = ClassBuilder.classBuilder().withName("Test1").withField(fieldBuilder().withName("name").withType(TypeBuilder.type().withName(CanonicalName.fromString("java.lang.String")).build()).build()).build();
verifier.verify(singletonList(aClass));
}
Aggregations