Search in sources :

Example 1 with ExaminerProduces

use of de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces 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();
}
Also used : ExaminerInject(de.strullerbaumann.visualee.examiner.cdi.ExaminerInject) ExaminerInstance(de.strullerbaumann.visualee.examiner.cdi.ExaminerInstance) ExaminerResource(de.strullerbaumann.visualee.examiner.cdi.ExaminerResource) ExaminerEJB(de.strullerbaumann.visualee.examiner.cdi.ExaminerEJB) ExaminerJPA(de.strullerbaumann.visualee.examiner.jpa.ExaminerJPA) ExaminerObserves(de.strullerbaumann.visualee.examiner.cdi.ExaminerObserves) ExaminerProduces(de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces) ExaminerEvent(de.strullerbaumann.visualee.examiner.cdi.ExaminerEvent)

Example 2 with ExaminerProduces

use of de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces 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);
}
Also used : ExaminerInject(de.strullerbaumann.visualee.examiner.cdi.ExaminerInject) JavaSource(de.strullerbaumann.visualee.source.entity.JavaSource) ExaminerProduces(de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces) Test(org.junit.Test)

Aggregations

ExaminerInject (de.strullerbaumann.visualee.examiner.cdi.ExaminerInject)2 ExaminerProduces (de.strullerbaumann.visualee.examiner.cdi.ExaminerProduces)2 ExaminerEJB (de.strullerbaumann.visualee.examiner.cdi.ExaminerEJB)1 ExaminerEvent (de.strullerbaumann.visualee.examiner.cdi.ExaminerEvent)1 ExaminerInstance (de.strullerbaumann.visualee.examiner.cdi.ExaminerInstance)1 ExaminerObserves (de.strullerbaumann.visualee.examiner.cdi.ExaminerObserves)1 ExaminerResource (de.strullerbaumann.visualee.examiner.cdi.ExaminerResource)1 ExaminerJPA (de.strullerbaumann.visualee.examiner.jpa.ExaminerJPA)1 JavaSource (de.strullerbaumann.visualee.source.entity.JavaSource)1 Test (org.junit.Test)1