public void testScaffoldGenerateWithSetup() throws Exception
{
Project project = projectHelper.createWebProject();
Imported<ScaffoldProvider> providerInstances = registry.getServices(ScaffoldProvider.class);
ScaffoldProvider scaffoldProvider = providerInstances.get();
Assert.assertFalse(scaffoldProvider.isSetup(new ScaffoldSetupContext("", project)));
try (WizardCommandController c = testHarness.createWizardController(ScaffoldGenerateCommand.class,
project.getRoot()))
{
c.initialize();
c.setValueFor("provider", "Mock Scaffold Provider");
c.setValueFor("webRoot", "");
Assert.assertTrue(c.isValid());
// Force the resolution of the next step. Without this ScaffoldGenerateCommandImpl.next() is not evaluated.
Assert.assertFalse(c.canMoveToNextStep());
Result result = c.execute();
// Verify successful execution
Assert.assertNotNull(result);
Assert.assertFalse(result instanceof Failed);
// Verify that the scaffold was setup
Assert.assertTrue(scaffoldProvider.isSetup(new ScaffoldSetupContext("", project)));
// Verify that the scaffold was generated
Assert.assertTrue(((MockProvider) scaffoldProvider).isGenerated());
}
}