コード例 #1
0
 @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()));
 }
コード例 #2
0
 @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"));
 }
コード例 #3
0
 @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"));
 }
コード例 #4
0
  public XjcGuavaPluginTest() throws Exception {
    aPackage = aModel._package("test");
    aClass = aPackage._class("AClass");

    aSetter = aClass.method(JMod.PUBLIC, aModel.VOID, "setField");

    aField = aClass.field(JMod.PRIVATE, aModel.INT, "field");
    anotherField = aClass.field(JMod.PRIVATE, aModel.BOOLEAN, "anotherField");
    aStaticField = aClass.field(JMod.STATIC | JMod.PUBLIC, aModel.SHORT, "staticField");
    aGetter = aClass.method(JMod.PUBLIC, aModel.INT, "getField");
    aGetter.body()._return(aField);
    final JVar setterParam = aSetter.param(aModel.INT, "field");
    aSetter.body().assign(aField, setterParam);

    aSuperClass = aPackage._class("ASuperClass");
    aClass._extends(aSuperClass);
    aSuperClassField = aSuperClass.field(JMod.PRIVATE, aModel.DOUBLE, "superClassField");
  }