Skip to content

Commit

Permalink
WINDUP-1792 Renaming generated files (#1248)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrizzi authored and jsight committed Dec 5, 2017
1 parent d6ab282 commit b6e0bb1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Expand Up @@ -46,6 +46,8 @@ public class GenerateJBossEjbDescriptorRuleProvider extends AbstractRuleProvider
{
private static final Logger LOG = Logger.getLogger(GenerateJBossEjbDescriptorRuleProvider.class.getName());
public static final String TEMPLATE_EJB_REPORT = "/reports/templates/jboss/jboss-ejb3.ftl";
private final String fileName = "jboss-ejb3";
private final String fileExtension = "xml";

@Override
public Configuration getConfiguration(RuleLoaderContext ruleLoaderContext)
Expand All @@ -71,7 +73,7 @@ public void perform(GraphRewrite event, EvaluationContext context)
@Override
public String toString()
{
return "Generate jboss-ejb3.xml";
return "Generate " + fileName + "." + fileExtension;
}
});
}
Expand All @@ -88,7 +90,7 @@ private void createReport(GraphRewrite event, EvaluationContext evaluationContex
ApplicationReportModel applicationReportModel = applicationReportService.create();
applicationReportModel.setReportPriority(300);
applicationReportModel.setDisplayInApplicationReportIndex(false);
applicationReportModel.setReportName("jboss-ejb3.xml");
applicationReportModel.setReportName(fileName + "." + fileExtension);
applicationReportModel.setProjectModel(projectModel);
applicationReportModel.setTemplatePath(TEMPLATE_EJB_REPORT);
applicationReportModel.setTemplateType(TemplateType.FREEMARKER);
Expand Down Expand Up @@ -116,13 +118,13 @@ private void createReport(GraphRewrite event, EvaluationContext evaluationContex
String ancestorFolder = projectModel.getName();
if (ejbDescriptor.getProjectModel().getName() == null || ancestorFolder.equals(ejbDescriptor.getProjectModel().getName()))
{
applicationReportModel.setReportFilename(reportService.getUniqueFilename("jboss-web", "xml", false, ancestorFolder));
applicationReportModel.setReportFilename(reportService.getUniqueFilename(fileName, fileExtension, false, ancestorFolder));
} else
{
applicationReportModel.setReportFilename(reportService.getUniqueFilename("jboss-web", "xml", false, ancestorFolder, ejbDescriptor.getProjectModel().getName()));
applicationReportModel.setReportFilename(reportService.getUniqueFilename(fileName, fileExtension, false, ancestorFolder, ejbDescriptor.getProjectModel().getName()));
}

LOG.info("Generated jboss-ejb3.xml for " + ejbDescriptor.getFilePath() + " at: " + applicationReportModel.getReportFilename());
LOG.info("Generated " + fileName + "." + fileExtension + " for " + ejbDescriptor.getFilePath() + " at: " + applicationReportModel.getReportFilename());

LinkModel newDescriptorLink = linkService.create();
newDescriptorLink.setDescription("JBoss EJB XML Descriptor - Generated by " + Util.WINDUP_BRAND_NAME_LONG);
Expand Down
Expand Up @@ -5,6 +5,7 @@
import org.jboss.forge.furnace.util.OperatingSystemUtils;
import org.jboss.windup.graph.GraphContext;
import org.jboss.windup.graph.GraphContextFactory;
import org.jboss.windup.graph.model.LinkModel;
import org.jboss.windup.graph.model.ProjectModel;
import org.jboss.windup.graph.model.WindupConfigurationModel;
import org.jboss.windup.graph.model.resource.FileModel;
Expand Down Expand Up @@ -85,7 +86,9 @@ private void checkEjbXmls(GraphContext context)
GraphService<EjbDeploymentDescriptorModel> ejbDescriptors = new GraphService<>(context,EjbDeploymentDescriptorModel.class);
for (EjbDeploymentDescriptorModel ejbDesc : ejbDescriptors.findAll())
{
Assert.assertEquals(1, Iterables.size(ejbDesc.getLinksToTransformedFiles()));
Iterable<LinkModel> linkModels = ejbDesc.getLinksToTransformedFiles();
linkModels.forEach(linkModel -> Assert.assertTrue(linkModel.getLink().endsWith("jboss-ejb3.xml")));
Assert.assertEquals(1, Iterables.size(linkModels));
}
}

Expand Down

0 comments on commit b6e0bb1

Please sign in to comment.