use of de.strullerbaumann.visualee.examiner.cdi.ExaminerInject in project visualee by Thomas-S-B.
the class DependencyAnalyzer method analyze.
public void analyze(String rootFolder) {
JavaSourceContainer.getInstance().clear();
JavaSourceContainer.getInstance().loadJavaFiles(rootFolder);
//Register Examiners
JavaSourceInspector.getInstance().registerExaminer(new ExaminerEJB());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerEvent());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerInject());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerInstance());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerJPA());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerObserves());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerProduces());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerResource());
JavaSourceInspector.getInstance().examine();
}
use of de.strullerbaumann.visualee.examiner.cdi.ExaminerInject in project visualee by Thomas-S-B.
the class DescriptionTest method testGenerateDescription2.
@Test
public void testGenerateDescription2() {
JavaSource javaSource;
String sourceCode;
// Produces
javaSource = JavaSourceFactory.getInstance().newJavaSource("Configurator");
sourceCode = "package org.lightfish.business.configuration.boundary;\n" + "import org.lightfish.business.configuration.entity.Configuration;\n" + "import java.util.Arrays;\n" + "import javax.annotation.PostConstruct;\n" + "import javax.ejb.Singleton;\n" + "import javax.enterprise.inject.Produces;\n" + "import javax.enterprise.inject.spi.InjectionPoint;\n" + "import javax.ejb.Startup;\n" + "import javax.inject.Inject;\n" + "import org.lightfish.business.configuration.control.ConfigurationStore;\n" + "@Startup\n" + "@Singleton\n" + "public class Configurator {\n" + " private Configuration configuration;\n" + " @Inject ConfigurationStore configurationStore;\n" + " @PostConstruct\n" + " public void initialize(){\n" + " this.configuration = configurationStore.retrieveConfiguration();\n" + " }\n" + " @Produces\n" + " public int getInteger(InjectionPoint ip) {\n" + " return Integer.parseInt(getString(ip));\n" + " }\n" + " @Produces\n" + " public boolean getBoolean(InjectionPoint ip) {\n" + " return Boolean.parseBoolean(getString(ip));\n" + " }\n" + " @Produces\n" + " public String getString(InjectionPoint ip) {\n" + " String name = ip.getMember().getName();\n" + " return this.configuration.get(name);\n" + " }\n" + " @Produces\n" + " public String[] getStringArray(InjectionPoint ip){\n" + " return asArray(getString(ip));\n" + " }\n" + " public String[] getStringArray(String key){\n" + " return asArray(getValue(key));\n" + " }\n" + " public String getValue(String key){\n" + " return this.configuration.get(key);\n" + " }\n" + " public String[] asArray(String value){\n" + " return value.split(\",\");\n" + " }\n" + "// public Map<String, String> getConfiguration() {\n" + "// return configuration;\n" + "// }\n" + " public int getValueAsInt(String interval) {\n" + " return Integer.parseInt(getValue(interval));\n" + " }\n" + " public void setValue(String key,int interval) {\n" + " this.setValue(key, String.valueOf(interval));\n" + " }\n" + " public void setValue(String key,boolean value) {\n" + " this.setValue(key, String.valueOf(value));\n" + " }\n" + " public void setValue(String key, String value) {\n" + " this.configuration.put(key, value);\n" + " configurationStore.save(configuration);\n" + " }\n" + " public void setArrayValue(String key, String[] values) {\n" + " StringBuilder sb = new StringBuilder();\n" + " for(String value:values){\n" + " if(sb.length()!=0){\n" + " sb.append(\",\");\n" + " }\n" + " sb.append(value);\n" + " }\n" + " this.setValue(key, String.valueOf(sb.toString()));\n" + " }\n" + "}\n";
javaSource.setSourceCode(sourceCode);
JavaSourceContainer.getInstance().add(javaSource);
JavaSourceInspector.getInstance().registerExaminer(new ExaminerInject());
JavaSourceInspector.getInstance().registerExaminer(new ExaminerProduces());
JavaSourceInspector.getInstance().examine();
String actual = Description.generateDescription(javaSource);
assertTrue(actual.indexOf("ConfigurationStore is injected") > 0);
assertTrue(actual.indexOf("Produces Integer") > 0);
assertTrue(actual.indexOf("Produces Boolean") > 0);
assertTrue(actual.indexOf("Produces String") > 0);
assertTrue(actual.indexOf("Produces String[]") > 0);
}
Aggregations