test_class.declarator: resourceFactory
test_class.modifier: @Inject
     private
test_class.original_string: @Inject
     private ResourceFactory resourceFactory;
test_class.type: ResourceFactory
test_class.var_name: resourceFactory
test_class.declarator: testHarness
test_class.modifier: @Inject
     private
test_class.original_string: @Inject
     private UITestHarness testHarness;
test_class.type: UITestHarness
test_class.var_name: testHarness
test_class.declarator: shellTest
test_class.modifier: @Inject
     private
test_class.original_string: @Inject
     private ShellTest shellTest;
test_class.type: ShellTest
test_class.var_name: shellTest
test_class.declarator: commandController
test_class.modifier: private
test_class.original_string: private CommandController commandController;
test_class.type: CommandController
test_class.var_name: commandController
test_class.file: dev-tools-java/src/test/java/org/jboss/forge/addon/devtools/java/JavaFormatSourcesCommandTest.java
test_class.identifier: JavaFormatSourcesCommandTest
test_case.body: @Test
     public void testFileFormattingWithProfileAndSourceInput() throws Exception
     {
  
        File formattedFile = File.createTempFile("FormattedSource", ".java");
        formattedFile.deleteOnExit();
        File unformattedFile = File.createTempFile("UnformattedSource", ".java");
        unformattedFile.deleteOnExit();
        File profile = File.createTempFile("FormatProfile", ".xml");
        profile.deleteOnExit();
  
        // Loading the sample formatted source
        Resource<File> unreifiedFormattedSource = resourceFactory.create(formattedFile);
        FileResource<?> formattedSource = unreifiedFormattedSource.reify(FileResource.class);
        Assert.assertNotNull(getClass().getResource("FormattedSource.java").openStream());
        formattedSource.setContents((getClass().getResource("FormattedSource.java").openStream()));
  
        // Loading the temporary unformatted source from the sample unformatted source
        Resource<File> unreifiedTempUnformattedSource = resourceFactory.create(unformattedFile);
        FileResource<?> tempUnformattedSource = unreifiedTempUnformattedSource.reify(FileResource.class);
        Assert.assertNotNull(getClass().getResource("UnformattedSource.java").openStream());
        tempUnformattedSource.setContents((getClass().getResource("UnformattedSource.java").openStream()));
  
        // Loading the sample format profile
        Resource<File> unreifiedProfile = resourceFactory.create(profile);
        XMLResource profileXML = unreifiedProfile.reify(XMLResource.class);
        Assert.assertNotNull(getClass().getResource("eclipse_profile.xml").openStream());
        profileXML.setContents((getClass().getResource("eclipse_profile.xml").openStream()));
  
        commandController.initialize();
        commandController.setValueFor("profilepath", profileXML);
        commandController.setValueFor("sources", tempUnformattedSource);
        commandController.setValueFor("profilename", "Eclipse [built-in]");
  
        commandController.execute();
  
        Assert.assertEquals(formattedSource.getContents(), tempUnformattedSource.getContents());
     }
test_case.class_method_signature: JavaFormatSourcesCommandTest.testFileFormattingWithProfileAndSourceInput()
test_case.full_signature: @Test public void testFileFormattingWithProfileAndSourceInput()
test_case.identifier: testFileFormattingWithProfileAndSourceInput
test_case.invocations: createTempFile deleteOnExit createTempFile deleteOnExit createTempFile deleteOnExit create reify assertNotNull openStream getResource getClass setContents openStream getResource getClass create reify assertNotNull openStream getResource getClass setContents openStream getResource getClass create reify assertNotNull openStream getResource getClass setContents openStream getResource getClass initialize setValueFor setValueFor setValueFor execute assertEquals getContents getContents
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testFileFormattingWithProfileAndSourceInput()
focal_class.declarator: profilepath
focal_class.modifier: private
focal_class.original_string: private UIInput<XMLResource> profilepath;
focal_class.type: UIInput<XMLResource>
focal_class.var_name: profilepath
focal_class.declarator: sources
focal_class.modifier: @SuppressWarnings("rawtypes")
     private
focal_class.original_string: @SuppressWarnings("rawtypes")
     private UIInputMany<FileResource> sources;
focal_class.type: UIInputMany<FileResource>
focal_class.var_name: sources
focal_class.declarator: profilename
focal_class.modifier: private
focal_class.original_string: private UIInput<String> profilename;
focal_class.type: UIInput<String>
focal_class.var_name: profilename
focal_class.file: dev-tools-java/src/main/java/org/jboss/forge/addon/devtools/java/JavaFormatSourcesCommand.java
focal_class.identifier: JavaFormatSourcesCommand
focal_class.class_method_signature: JavaFormatSourcesCommand.getMetadata(UIContext context)
focal_class.full_signature: @Override public UICommandMetadata getMetadata(UIContext context)
focal_class.identifier: getMetadata
focal_class.modifiers: @Override public
focal_class.parameters: (UIContext context)
focal_class.return: UICommandMetadata
focal_class.signature: UICommandMetadata getMetadata(UIContext context)
focal_class.class_method_signature: JavaFormatSourcesCommand.initializeUI(UIBuilder builder)
focal_class.full_signature: @Override public void initializeUI(UIBuilder builder)
focal_class.identifier: initializeUI
focal_class.modifiers: @Override public
focal_class.parameters: (UIBuilder builder)
focal_class.return: void
focal_class.signature: void initializeUI(UIBuilder builder)
focal_class.class_method_signature: JavaFormatSourcesCommand.execute(UIExecutionContext context)
focal_class.full_signature: @SuppressWarnings({ "rawtypes" }) @Override public Result execute(UIExecutionContext context)
focal_class.identifier: execute
focal_class.modifiers: @SuppressWarnings({ "rawtypes" }) @Override public
focal_class.parameters: (UIExecutionContext context)
focal_class.return: Result
focal_class.signature: Result execute(UIExecutionContext context)
focal_class.class_method_signature: JavaFormatSourcesCommand.format(List<FileResource<?>> fileResourceList, Properties formatProfile)
focal_class.full_signature: private static void format(List<FileResource<?>> fileResourceList, Properties formatProfile)
focal_class.identifier: format
focal_class.modifiers: private static
focal_class.parameters: (List<FileResource<?>> fileResourceList, Properties formatProfile)
focal_class.return: void
focal_class.signature: void format(List<FileResource<?>> fileResourceList, Properties formatProfile)
focal_class.superclass: extends AbstractUICommand
focal_method.body: @SuppressWarnings({ "rawtypes" })
     @Override
     public Result execute(UIExecutionContext context) throws Exception
     {
        XMLResource formatProfileLocation = profilepath.getValue();
        Iterable<FileResource> formatSources = sources.getValue();
        String formatterName = profilename.getValue();
        List<FileResource<?>> fileResourceList = new ArrayList<>();
  
        if (!formatSources.iterator().hasNext())
        {
           UISelection<Resource> us = context.getUIContext().getInitialSelection();
           Resource<?> rs = us.get();
  
           FileResource<?> fr = rs.reify(FileResource.class);
           fileResourceList.add(fr);
        }
  
        else
           for (FileResource<?> fileResource : formatSources)
              fileResourceList.add(fileResource);
  
        Properties formatProfile = null;
  
        if (formatProfileLocation == null || !formatProfileLocation.exists())
           formatProfile = null;
  
        else
        {
           try (InputStream is = formatProfileLocation.getResourceInputStream())
           {
              FormatterProfileReader reader = FormatterProfileReader.fromEclipseXml(is);
              formatProfile = reader.getPropertiesFor(formatterName);
           }
        }
        if (formatProfile != null)
        {
           format(fileResourceList, formatProfile);
           return Results.success("Files Formatted Sucessfully");
        }
        else
        {
           return Results.fail("No format profile found to be applied");
        }
     }
focal_method.class_method_signature: JavaFormatSourcesCommand.execute(UIExecutionContext context)
focal_method.full_signature: @SuppressWarnings({ "rawtypes" }) @Override public Result execute(UIExecutionContext context)
focal_method.identifier: execute
focal_method.invocations: getValue getValue getValue hasNext iterator getInitialSelection getUIContext get reify add add exists getResourceInputStream fromEclipseXml getPropertiesFor format success fail
focal_method.modifiers: @SuppressWarnings({ "rawtypes" }) @Override public
focal_method.parameters: (UIExecutionContext context)
focal_method.return: Result
focal_method.signature: Result execute(UIExecutionContext context)