@Test public void testGenerateHashCode() throws ClassNotFoundException { plugin.generateHashCodeMethod(aModel, aClass); final JMethod generatedMethod = aClass.getMethod("hashCode", new JType[] {}); assertThat(generatedMethod, not(nullValue())); assertThat(generatedMethod.type().fullName(), equalTo("int")); }
@Test public void testGenerateToString() { plugin.generateToStringMethod(aModel, aClass); final JMethod generatedMethod = aClass.getMethod("toString", new JType[0]); assertThat(generatedMethod, not(nullValue())); assertThat(generatedMethod.type().fullName(), equalTo(String.class.getName())); }
@Test public void testGenerateEquals() throws ClassNotFoundException { plugin.generateEqualsMethod(aModel, aClass); final JMethod generatedMethod = aClass.getMethod("equals", new JType[] {aModel.parseType("java.lang.Object")}); assertThat(generatedMethod, not(nullValue())); assertThat(generatedMethod.type().fullName(), equalTo("boolean")); }
@Test public void testIsStatic() { assertThat(plugin.isStatic(aStaticField), equalTo(true)); assertThat(plugin.isStatic(aField), equalTo(false)); }
@Test public void testGetSuperclassFields() { assertThat(plugin.getSuperclassFields(aClass), equalTo(Arrays.asList(aSuperClassField))); }
@Test public void testGetInstanceFields() { final Collection<JFieldVar> instanceFields = plugin.getInstanceFields(aClass.fields().values()); assertThat(instanceFields, not(hasItem(aStaticField))); assertThat(instanceFields, not(empty())); }