[forge-dev] hasFacet return false after instalation in Forge test

George Gastaldi ggastald at redhat.com
Sun Feb 26 20:38:17 EST 2017


Yes, that behavior exists since Forge 2.0.0.Final was released.

Glad it works for you! Cheers!

Em 26 de fev de 2017 22:36, "Rafael Pestano" <rmpestano at gmail.com> escreveu:

> Yea! thank you very much George.
>
> I think that wasn't necessary in older forge versions, right?  anyway, it's
> all green now ;)
>
> 2017-02-26 15:10 GMT-03:00 George Gastaldi <ggastald at redhat.com>:
>
> > That's because the original Project object remains unchanged and you need
> > to refresh it. Try calling ProjectFactory.findProject again after your
> > command is executed
> >
> > Em 26 de fev de 2017 15:04, "Rafael Pestano" <rmpestano at gmail.com>
> > escreveu:
> >
> > > Hi guys,
> > >
> > > I have a simple test which runs the setup command and then verifies if
> > the
> > > facet was installed:
> > >
> > > @Test
> > > public void shouldGenerateSwaggerResources() throws Exception {
> > >     Result result = shellTest.execute("swagger-setup", 25,
> > > TimeUnit.SECONDS);
> > >     Assert.assertThat(result, not(instanceOf(Failed.class)));
> > >     Assert.assertThat(result.getMessage(), is(equalTo("Swagger setup
> > > completed successfully!")));
> > >     Assert.assertTrue(project.hasFacet(SwaggerFacet.class));
> > >
> > >
> > > the problem is that the assertion in returning false and test is
> failing.
> > > Note that the setup command runs with success and also I can confirm
> the
> > > facet is installed when I run the plugin on the IDE.
> > >
> > > here's the setup command:
> > >
> > > @Override
> > >
> > > public Result execute(UIExecutionContext context) throws Exception {
> > >     Project project = getSelectedProject(context);
> > >
> > >     boolean execute = true;
> > >     if (project.hasFacet(SwaggerFacet.class) &&
> > > project.getFacet(SwaggerFacet.class).isInstalled()) {
> > >         execute = context.getPrompt().promptBoolean("Swagger plugin is
> > > already installed, override it?");
> > >     }
> > >
> > >     if (execute) {
> > >         swaggerConfiguration.setResourcesDir(resourcesDir.getValue());
> > >         SwaggerFacet facet = facetFactory.create(project,
> > > SwaggerFacet.class);
> > >         facet.setConfiguration(swaggerConfiguration);
> > >         facetFactory.install(project, facet);
> > >         copySwaggerUIResources(facet);
> > >         return Results.success("Swagger setup completed
> successfully!");
> > >     } else {
> > >         return Results.success();
> > >     }
> > >
> > > }
> > >
> > >
> > > When I debug the test I can see the SwaggerFacet#isInstalled returns
> true
> > > after setup command.
> > >
> > > The code can be found here: https://github.com/rmpestano/swagger-addon
> > >
> > >
> > > Any help is appreciated.
> > >
> > > --
> > > Att,
> > >
> > > Rafael M. Pestano
> > >
> > > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> > > http://rpestano.wordpress.com/
> > > @realpestano
> > > _______________________________________________
> > > forge-dev mailing list
> > > forge-dev at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/forge-dev
> > >
> > _______________________________________________
> > forge-dev mailing list
> > forge-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/forge-dev
> >
>
>
>
> --
> Att,
>
> Rafael M. Pestano
>
> Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> http://rpestano.wordpress.com/
> @realpestano
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-dev
>


More information about the forge-dev mailing list