Package org.jboss.forge.roaster.model.source

Examples of org.jboss.forge.roaster.model.source.EnumConstantSource


   public void testSetConstructorArguments()
   {
      int i = javaEnum.getMethods().size();
      javaEnum.addMethod().setConstructor(true).setParameters("int n, String s");
      assertEquals("int", javaEnum.getMethods().get(i).getParameters().get(0).getType().getName());
      EnumConstantSource foo = javaEnum.getEnumConstant("FOO");
      assertTrue(foo.getConstructorArguments().isEmpty());
      foo.setConstructorArguments("666", "null");
      assertEquals(2, foo.getConstructorArguments().size());
      assertEquals("666", foo.getConstructorArguments().get(0));
      assertEquals("null", foo.getConstructorArguments().get(1));
      foo.setConstructorArguments((String[]) null);
      assertTrue(foo.getConstructorArguments().isEmpty());
      foo.setConstructorArguments("0", "\"foo\"");
      assertEquals(2, foo.getConstructorArguments().size());
      assertEquals("0", foo.getConstructorArguments().get(0));
      assertEquals("\"foo\"", foo.getConstructorArguments().get(1));
      foo.setConstructorArguments();
      assertTrue(foo.getConstructorArguments().isEmpty());
   }
View Full Code Here


   }

   @Test
   public void testAddRemoveBody()
   {
      EnumConstantSource foo = javaEnum.getEnumConstant("FOO");
      final Pattern emptyBody = Pattern.compile("\\{\\s*\\}$");
      assertFalse(emptyBody.matcher(foo.toString()).find());
      foo.getBody();
      assertTrue(emptyBody.matcher(foo.toString()).find());
      foo.removeBody();
      assertFalse(emptyBody.matcher(foo.toString()).find());
   }
View Full Code Here

   }

   @Test
   public void testBodyAssertions()
   {
      EnumConstantSource foo = javaEnum.getEnumConstant("FOO");
      EnumConstantSource.Body body = foo.getBody();
      assertTrue(body.isClass());
      assertFalse(body.isInterface());
      assertFalse(body.isEnum());
      assertFalse(body.isAnnotation());
      assertEquals(javaEnum, body.getEnclosingType());
View Full Code Here

   }

   @Test
   public void testAddRemoveBodyImports()
   {
      EnumConstantSource foo = javaEnum.getEnumConstant("FOO");
      EnumConstantSource.Body body = foo.getBody();
      assertFalse(body.hasImport(Strings.class));
      assertFalse(javaEnum.hasImport(Strings.class));
      body.addImport(Strings.class);
      assertTrue(body.hasImport(Strings.class));
      assertTrue(javaEnum.hasImport(Strings.class));
View Full Code Here

   }

   @Test
   public void testAddRemoveBodyMethod()
   {
      EnumConstantSource foo = javaEnum.getEnumConstant("FOO");
      EnumConstantSource.Body body = foo.getBody();
      MethodSource<EnumConstantSource.Body> fooAction = body.addMethod().setName("fooAction").setReturnType(Void.TYPE);
      assertEquals(fooAction, body.getMethods().get(0));
      assertEquals(fooAction, body.getMembers().get(0));
      body.removeMethod(fooAction);
      assertTrue(body.getMethods().isEmpty());
View Full Code Here

   }

   @Test
   public void testAddRemoveBodyField()
   {
      EnumConstantSource foo = javaEnum.getEnumConstant("FOO");
      EnumConstantSource.Body body = foo.getBody();
      FieldSource<EnumConstantSource.Body> fooField = body.addField().setName("fooField").setType(String.class);
      assertEquals(fooField, body.getFields().get(0));
      assertEquals(fooField, body.getMembers().get(0));
      body.removeField(fooField);
      assertTrue(body.getFields().isEmpty());
View Full Code Here

   @Override
   public void resetTests()
   {
      InputStream stream = EnumConstantAnnotationTest.class
               .getResourceAsStream("/org/jboss/forge/grammar/java/MockAnnotatedEnumConstant.java");
      EnumConstantSource field = Roaster.parse(JavaEnumSource.class, stream).getEnumConstants().get(0);
      setTarget(field);
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.roaster.model.source.EnumConstantSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.