Project project = projectFactory.createTempProject();
facetFactory.install(project, ResourcesFacet.class);
facetFactory.install(project, JavaSourceFacet.class);
JavaSourceFacet sourceFacet = project.getFacet(JavaSourceFacet.class);
JavaResource resource = sourceFacet
.saveJavaSource(Roaster.parse(JavaClassSource.class, "package org.example; public class DemoBean {}"));
MethodSource<?> method = operations.addValidatorMethod(resource, "validateUsername");
Assert.assertEquals(3, method.getParameters().size());
JavaClassSource source = resource.getJavaType();
Assert.assertEquals(1, source.getMethods().size());
Assert.assertEquals(method.toSignature(), source.getMethods().get(0).toSignature());
}