当前位置: 首页>>代码示例>>Java>>正文


Java JavaClassSource.getAnnotation方法代码示例

本文整理汇总了Java中org.jboss.forge.roaster.model.source.JavaClassSource.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java JavaClassSource.getAnnotation方法的具体用法?Java JavaClassSource.getAnnotation怎么用?Java JavaClassSource.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.roaster.model.source.JavaClassSource的用法示例。


在下文中一共展示了JavaClassSource.getAnnotation方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUniqueComponentPrefix

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private String getUniqueComponentPrefix(JavaClassSource clazz) {
    AnnotationSource<JavaClassSource> annotation = clazz.getAnnotation(Unique.class);
    if (annotation != null) {
        return annotation.getStringValue("prefix");
    }
    return "is";
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:8,代码来源:CustomPrefixDataProvider.java

示例2: extractContextNames

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private List<String> extractContextNames(JavaClassSource clazz) {
    AnnotationSource<JavaClassSource> annotation =  clazz.getAnnotation(Contexts.class);
    if (annotation != null) {
        return Arrays.asList(annotation.getStringArrayValue("names"));
    }
    return new ArrayList<>();
}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:8,代码来源:ContextsComponentDataProvider.java

示例3: getComponentNames

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
List<String> getComponentNames(JavaClassSource type) {
    AnnotationSource<JavaClassSource> annotation = type.getAnnotation(CustomComponentName.class);
    if (annotation != null) {
        return Arrays.asList(annotation.getStringArrayValue("componentNames"));

    } else {
        return new ArrayList<>();
    }

}
 
开发者ID:Rubentxu,项目名称:Entitas-Java,代码行数:11,代码来源:ComponentDataProvider.java

示例4: should_create_incontainer_test

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_create_incontainer_test() throws Exception
{
   assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
   try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
            project.getRoot()))
   {
      controller.initialize();
      controller.setValueFor("targetPackage", "org.example");
      controller.setValueFor("named", "HelloWorldTest");

      assertThat(controller.isValid(), is(true));
      final AtomicBoolean flag = new AtomicBoolean();
      controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
      {
         @Override
         public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
         {
            if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
            {
               flag.set(true);
            }
         }
      });
      controller.execute();
      assertThat(flag.get(), is(true));
   }
   JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
            .getTestJavaResource("org.example.HelloWorldTest");
   assertThat(javaResource.exists(), is(true));
   JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
   assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));
   final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
   assertThat(defaultDeployment, is((notNullValue())));
   assertThat(defaultDeployment.getValues().size(), is(0));

   final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
   assertThat(testMethod, is(notNullValue()));
   assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));

}
 
开发者ID:forge,项目名称:wildfly-swarm-addon,代码行数:42,代码来源:CreateTestClassCommandTest.java

示例5: should_create_asclient_test

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_create_asclient_test() throws Exception
{
   assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
   try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
            project.getRoot()))
   {
      controller.initialize();
      controller.setValueFor("targetPackage", "org.example");
      controller.setValueFor("named", "HelloWorldTest");
      controller.setValueFor("asClient", true);

      assertThat(controller.isValid(), is(true));
      final AtomicBoolean flag = new AtomicBoolean();
      controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
      {
         @Override
         public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
         {
            if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
            {
               flag.set(true);
            }
         }
      });
      controller.execute();
      assertThat(flag.get(), is(true));
   }

   JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
            .getTestJavaResource("org.example.HelloWorldTest");
   assertThat(javaResource.exists(), is(true));
   JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
   assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));

   final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
   assertThat(defaultDeployment, is((notNullValue())));
   final String testable = defaultDeployment.getLiteralValue("testable");
   assertThat(testable, is("false"));

   final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
   assertThat(testMethod, is(notNullValue()));
   assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));

}
 
开发者ID:forge,项目名称:wildfly-swarm-addon,代码行数:46,代码来源:CreateTestClassCommandTest.java

示例6: should_set_archivetype_test

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_set_archivetype_test() throws Exception
{
   assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
   try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
            project.getRoot()))
   {
      controller.initialize();
      controller.setValueFor("targetPackage", "org.example");
      controller.setValueFor("named", "HelloWorldTest");
      controller.setValueFor("archiveType", "WAR");

      assertThat(controller.isValid(), is(true));
      final AtomicBoolean flag = new AtomicBoolean();
      controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
      {
         @Override
         public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
         {
            if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
            {
               flag.set(true);
            }
         }
      });
      controller.execute();
      assertThat(flag.get(), is(true));
   }

   JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
            .getTestJavaResource("org.example.HelloWorldTest");
   assertThat(javaResource.exists(), is(true));
   JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
   assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));

   final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
   assertThat(defaultDeployment, is((notNullValue())));
   final String testable = defaultDeployment.getLiteralValue("type");
   assertThat(testable, is("DefaultDeployment.Type.WAR"));

   final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
   assertThat(testMethod, is(notNullValue()));
   assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));

}
 
开发者ID:forge,项目名称:wildfly-swarm-addon,代码行数:46,代码来源:CreateTestClassCommandTest.java

示例7: should_set_mainclass_test

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Test
public void should_set_mainclass_test() throws Exception
{
   assertThat(project.hasFacet(WildFlySwarmFacet.class), is(true));
   try (CommandController controller = uiTestHarness.createCommandController(CreateTestClassCommand.class,
            project.getRoot()))
   {
      controller.initialize();
      controller.setValueFor("targetPackage", "org.example");
      controller.setValueFor("named", "HelloWorldTest");
      controller.setValueFor("archiveType", "WAR");
      controller.setValueFor("mainClass", "org.example.Main");

      assertThat(controller.isValid(), is(true));
      final AtomicBoolean flag = new AtomicBoolean();
      controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener()
      {
         @Override
         public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result)
         {
            if (result.getMessage().equals("Test Class org.example.HelloWorldTest was created"))
            {
               flag.set(true);
            }
         }
      });
      controller.execute();
      assertThat(flag.get(), is(true));
   }

   JavaResource javaResource = project.getFacet(JavaSourceFacet.class)
            .getTestJavaResource("org.example.HelloWorldTest");
   assertThat(javaResource.exists(), is(true));
   JavaClassSource testClass = Roaster.parse(JavaClassSource.class, javaResource.getContents());
   assertThat(testClass.getAnnotation(RunWith.class), is((notNullValue())));

   final AnnotationSource<JavaClassSource> defaultDeployment = testClass.getAnnotation("DefaultDeployment");
   assertThat(defaultDeployment, is((notNullValue())));
   final String testable = defaultDeployment.getLiteralValue("type");
   assertThat(testable, is("DefaultDeployment.Type.WAR"));

   final String main = defaultDeployment.getLiteralValue("main");
   assertThat(main, is("org.example.Main"));

   final MethodSource<JavaClassSource> testMethod = testClass.getMethod("should_start_service");
   assertThat(testMethod, is(notNullValue()));
   assertThat(testMethod.getAnnotation(Test.class), is(notNullValue()));

}
 
开发者ID:forge,项目名称:wildfly-swarm-addon,代码行数:50,代码来源:CreateTestClassCommandTest.java


注:本文中的org.jboss.forge.roaster.model.source.JavaClassSource.getAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。