/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.fabric8.forge.camel.commands;

import java.io.File;
import javax.inject.Inject;

import io.fabric8.forge.camel.commands.project.CamelListComponentCommand;
import io.fabric8.forge.camel.commands.project.CamelSetupCommand;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.ProjectFactory;
import org.jboss.forge.addon.ui.controller.CommandController;
import org.jboss.forge.addon.ui.result.Failed;
import org.jboss.forge.addon.ui.result.Result;
import org.jboss.forge.addon.ui.test.UITestHarness;
import org.jboss.forge.arquillian.AddonDependencies;
import org.jboss.forge.arquillian.AddonDependency;
import org.jboss.forge.arquillian.archive.AddonArchive;
import org.jboss.forge.furnace.repositories.AddonDependencyEntry;
import org.jboss.forge.furnace.util.OperatingSystemUtils;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class NewComponentInstanceTest {

    @Inject
    private UITestHarness testHarness;

    @Inject
    private ProjectFactory projectFactory;

    @Deployment
    @AddonDependencies({
            @AddonDependency(name = "org.jboss.forge.addon:maven"),
            @AddonDependency(name = "org.jboss.forge.addon:projects"),
            @AddonDependency(name = "org.jboss.forge.addon:ui"),
            @AddonDependency(name = "org.jboss.forge.addon:ui-test-harness"),
            @AddonDependency(name = "org.jboss.forge.addon:shell-test-harness"),
            @AddonDependency(name = "io.fabric8.forge:camel")
    })
    public static AddonArchive getDeployment() {
        AddonArchive archive = ShrinkWrap
                .create(AddonArchive.class)
                .addBeansXML()
                .addAsAddonDependencies(
                        AddonDependencyEntry.create("org.jboss.forge.furnace.container:cdi"),
                        AddonDependencyEntry.create("org.jboss.forge.addon:ui"),
                        AddonDependencyEntry.create("org.jboss.forge.addon:ui-test-harness"),
                        AddonDependencyEntry.create("org.jboss.forge.addon:shell-test-harness"),
                        AddonDependencyEntry.create("org.jboss.forge.addon:projects"),
                        AddonDependencyEntry.create("org.jboss.forge.addon:maven"),
                        AddonDependencyEntry.create("io.fabric8.forge:camel")
                );
        return archive;
    }

    @Test
    public void testSomething() throws Exception {
        File tempDir = OperatingSystemUtils.createTempDir();
        try {
            Project project = projectFactory.createTempProject();
            Assert.assertNotNull("Should have created a project", project);

            CommandController command = testHarness.createCommandController(CamelSetupCommand.class);
            command.initialize();

            Result result = command.execute();
            Assert.assertFalse("Should setup Camel in the project", result instanceof Failed);

            command = testHarness.createCommandController(CamelListComponentCommand.class);
            command.initialize();
/*
           Assert.assertFalse(command.canMoveToNextStep());
           command.setValueFor("named", "test");
           command.setValueFor("targetLocation", tempDir);
           command.setValueFor("topLevelPackage", "org.example");
           command.setValueFor("type", "norequirements");
           Assert.assertEquals("norequirements", InputComponents.getValueFor(command.getInputs().get("type")).toString());
*/
            result = command.execute();
            System.out.println("Got result: " + result);
        } finally {
            tempDir.delete();
        }
    }
}

@@ -3,233 +3,58 @@
 *%0A *
-%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF
+  Copyright 2005-2014 Red Hat, Inc.%0A *%0A *  Red Hat
  lic
@@ -72,17 +72,17 @@
 file to 
-Y
+y
 ou under
@@ -106,22 +106,23 @@
 se, 
-V
+v
 ersion
+%0A * 
  2.0
-%0A *
  (th
@@ -185,16 +185,17 @@
 ance
+%0A * 
  with
-%0A *
  the
@@ -250,16 +250,20 @@
 at%0A *%0A *
+    
  http://
@@ -303,16 +303,17 @@
 .0%0A *%0A *
+ 
  Unless 
@@ -375,16 +375,17 @@
 tware%0A *
+ 
  distrib
@@ -445,16 +445,17 @@
 ASIS,%0A *
+ 
  WITHOUT
@@ -510,16 +510,20 @@
 press or
+%0A * 
  implied
@@ -523,19 +523,17 @@
 implied.
-%0A *
+ 
  See the
@@ -576,16 +576,20 @@
 overning
+%0A * 
  permiss
@@ -596,19 +596,16 @@
 ions and
-%0A *
  limitat
@@ -3579,32 +3579,51 @@
 tupCommand.class
+, project.getRoot()
 );%0A            c
@@ -3880,108 +3880,31 @@
 lass
-);%0A            command.initialize();%0A/*%0A           Assert.assertFalse(command.canMoveToNextStep
+, project.getRoot
 ());%0A
+ 
     
@@ -3922,38 +3922,23 @@
 and.
-setValueFor(%22named%22, %22test%22
+initialize(
 );%0A
+%0A
     
@@ -3948,180 +3948,38 @@
     
-command.setValueFor(%22targetLocation%22, tempDir);%0A           command.setValueFor(%22topLevelPackage%22, %22org.example%22);%0A           command.setValueFor(%22type%22, %22norequirements%22
+ result = command.execute(
 );%0A
+ 
     
@@ -4002,204 +4002,57 @@
 sert
-Equ
+F
 als
+e
 (%22
-norequirements%22, InputComponents.getValueFor(command.getInputs().get(%22type%22)).toString());%0A*/%0A            result = command.execute();%0A            System.out.println(%22Got result: %22 + result
+Should not fail%22, result instanceof Failed
 );%0A 

Fix forge unit test