Package org.jboss.forge.addon.parser.java.resources

Examples of org.jboss.forge.addon.parser.java.resources.JavaResource


      Assert.assertTrue(controller.canExecute());
      Result result = controller.execute();
      Assert.assertThat(result, is(not(instanceOf(Failed.class))));

      JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
      JavaResource javaResource = facet.getJavaResource("org.jboss.forge.test.CreditCardType");
      Assert.assertNotNull(javaResource);
      Assert.assertThat(javaResource.getJavaType(), is(instanceOf(JavaClass.class)));

      // overwriting the class file
      controller = getInitializedController(JavaClassCommand.class, project.getRoot());
      Assert.assertFalse(controller.isValid());
      controller.setValueFor("overwrite", "true");
View Full Code Here


      Assert.assertTrue(controller.canExecute());
      Result result = controller.execute();
      Assert.assertThat(result, is(not(instanceOf(Failed.class))));

      JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
      JavaResource javaResource = facet.getJavaResource("org.jboss.forge.test.MyException");
      Assert.assertNotNull(javaResource);
      Assert.assertThat(javaResource.getJavaType(), is(instanceOf(JavaClass.class)));
   }
View Full Code Here

      Assert.assertTrue(controller.canExecute());
      Result result = controller.execute();
      Assert.assertThat(result, is(not(instanceOf(Failed.class))));

      JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
      JavaResource javaResource = facet.getJavaResource("org.jboss.forge.test.CreditCardType");
      Assert.assertNotNull(javaResource);
      Assert.assertThat(javaResource.getJavaType(), is(instanceOf(JavaInterface.class)));

      // overwriting the interface file
      controller = getInitializedController(JavaInterfaceCommand.class, project.getRoot());
      Assert.assertFalse(controller.isValid());
      controller.setValueFor("overwrite", "true");
View Full Code Here

      JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
      JavaEnumSource javaEnum = Roaster.parse(JavaEnumSource.class,
               "package org.jboss.forge.test; public enum CreditCardType{}");
      facet.saveJavaSource(javaEnum);

      JavaResource javaResource = facet.getJavaResource("org.jboss.forge.test.CreditCardType");
      Assert.assertNotNull(javaResource);
      Assert.assertThat(javaResource.getJavaType(), is(instanceOf(JavaEnum.class)));

      CommandController controller = testHarness.createCommandController(JavaEnumConstantCommand.class,
               javaResource);
      controller.initialize();
      controller.setValueFor("arguments", Arrays.asList("VISA", "AMERICAN_EXPRESS", "MASTERCARD"));
      Assert.assertTrue(controller.isValid());
      Assert.assertTrue(controller.canExecute());
      Result result = controller.execute();
      Assert.assertThat(result, is(not(instanceOf(Failed.class))));

      javaResource = facet.getJavaResource("org.jboss.forge.test.CreditCardType");
      JavaEnumSource enumClass = javaResource.getJavaType();
      List<EnumConstantSource> enumConstants = enumClass.getEnumConstants();
      Assert.assertEquals(3, enumConstants.size());

      Assert.assertEquals("VISA", enumConstants.get(0).getName());
      Assert.assertEquals("AMERICAN_EXPRESS", enumConstants.get(1).getName());
View Full Code Here

      }
      String path = relativePath.trim().endsWith(".java")
               ? relativePath.substring(0, relativePath.lastIndexOf(".java")) : relativePath;

      path = Packages.toFileSyntax(path) + ".java";
      JavaResource target = sourceDir.getChildOfType(JavaResource.class, path);
      return target;
   }
View Full Code Here

      {
         getDeployment.addAnnotation("Dependencies").setLiteralValue("{" + annotationBody + "}");
      }

      JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
      JavaResource javaResource = facet.saveTestJavaSource(javaClass);
      uiContext.setSelection(javaResource);
      return Results.success("Test class " + javaClass.getQualifiedName() + " created");
   }
View Full Code Here

   }

   @Override
   public Result execute(UIExecutionContext context) throws Exception
   {
      JavaResource javaResource = (JavaResource) context.getUIContext().getInitialSelection().get();
      JavaClassSource commandClass = javaResource.getJavaType();
      commandClass = createCommand(commandClass, commandName.getValue(), categories.getValue());
      javaResource.setContents(commandClass);
      return Results.success("Annotated UICommand created");
   }
View Full Code Here

      boolean isEmbeddable = false;
      try
      {
         if (this.java != null)
         {
            JavaResource javaResource = java.getJavaResource(type);
            JavaSource<?> javaSource = javaResource.getJavaType();
            if (javaSource instanceof JavaClass)
            {
               JavaClass<?> klass = (JavaClass<?>) javaSource;
               if (klass.hasAnnotation(Embeddable.class))
               {
View Full Code Here

   @Override
   public JavaResource newEntity(DirectoryResource target, String entityName, String entityPackage,
            GenerationType idStrategy, String tableName)
   {
      JavaClassSource javaClass = createJavaEntityClass(entityName, entityPackage, idStrategy, tableName);
      JavaResource javaResource = getJavaResource(target, javaClass.getName());
      javaResource.setContents(javaClass);
      return javaResource;
   }
View Full Code Here

  
   @Override
   public JavaResource newEmbeddableEntity(DirectoryResource target, String entityName, String entityPackage)
   {
      JavaClassSource javaClass = createJavaEmbeddableClass(entityName, entityPackage);
      JavaResource javaResource = getJavaResource(target, javaClass.getName());
      javaResource.setContents(javaClass);
      return javaResource;
   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.parser.java.resources.JavaResource

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.