ArchetypeGeneratorService { @Path("/generate") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public GenerationTaskDescriptor generate(@Context UriInfo uriInfo, @QueryParam("groupId") String groupId, @QueryParam("artifactId") String artifactId, @QueryParam("version") String version, MavenArchetype archetype) throws ServerException { ArchetypeGenerator.GenerationTask task = archetypeGenerator.generateFromArchetype(archetype, groupId, artifactId, version); final String statusUrl = uriInfo.getBaseUriBuilder().path(getClass()).path(getClass(), "getStatus").build(task.getId()).toString(); return DtoFactory.getInstance().createDto(GenerationTaskDescriptor.class).withStatusUrl(statusUrl); }  @Path("/generate") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) GenerationTaskDescriptor generate(@Context UriInfo uriInfo,
                                             @QueryParam("groupId") String groupId,
                                             @QueryParam("artifactId") String artifactId,
                                             @QueryParam("version") String version,
                                             MavenArchetype archetype); @GET @Path("/status/{id}") @Produces(MediaType.APPLICATION_JSON) GenerationTaskDescriptor getStatus(@Context UriInfo uriInfo, @PathParam("id") String id); @GET @Path("/download/{id}") Response downloadGeneratedProject(@PathParam("id") String id);  }
@Test public void testGenerate() throws Exception { MavenArchetype archetype = DtoFactory.getInstance().createDto(MavenArchetype.class) .withGroupId("archetypeGroupId") .withArtifactId("archetypeArtifactId") .withVersion("archetypeVersion"); when(archetypeGenerator.generateFromArchetype((MavenArchetype)anyObject(), anyString(), anyString(), anyString())) .thenReturn(taskMock); GenerationTaskDescriptor task = service.generate(uriInfo, "groupId", "artifactId", "version", archetype); verify(archetypeGenerator).generateFromArchetype(eq(archetype), eq("groupId"), eq("artifactId"), eq("version")); Assert.assertEquals("http: }