### Question:
ComponentResource { @GET @Path("/{namespace}/{name}/{version}") @Timed @UnitOfWork(transactional = false) @ApiOperation(value = "Get component based on namespace, name and version", response = ComponentDomain.class) public Response get(@PathParam("namespace") final String namespace, @PathParam("name") final String name, @PathParam("version") final String version) { final Set<ComponentDomain> components = service.search(namespace, name, version); if (components.isEmpty()) { throw new NotFoundException(String.format("Component with namespace: %s, name: %s, version: %s not found", namespace, name, version)); } return Response.ok().entity(components.iterator().next()).build(); }  @POST @Consumes(MediaType.APPLICATION_JSON) @Timed @UnitOfWork @UserRequired @ApiOperation(value = "Save computation", response = ComponentDomain.class) Response save(@NotNull @Valid final ComponentDomain component); @GET @Path("/versions") @Timed @UnitOfWork(transactional = false) @ApiOperation(value = "Get all computation grouped by version", response = ComponentDomain.class) Response getAllGroupedByVersion(@QueryParam("namespace") final String namespace,
            @QueryParam("name") final String name); @GET @Path("/{namespace}/{name}/{version}") @Timed @UnitOfWork(transactional = false) @ApiOperation(value = "Get component based on namespace, name and version", response = ComponentDomain.class) Response get(@PathParam("namespace") final String namespace, @PathParam("name") final String name,
            @PathParam("version") final String version); @GET @Timed @UnitOfWork(transactional = false) @ApiOperation(value = "Searches component based on param", response = Set.class) Response search(@QueryParam("namespace") final String namespace, @QueryParam("name") final String name,
            @QueryParam("version") final String version); @GET @Path("/{id}") @UnitOfWork(transactional = false) @ApiOperation(value = "Get component by id", response = ComponentDomain.class) Response get(@PathParam("id") final int internalId); @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/register") @Timed @UnitOfWork @UserRequired @ApiOperation(value = "Registers a processor/source jar from url", response = List.class) Response register(@Context final UriInfo uriinfo, @QueryParam("url") final String url); @UserRequired @POST @Consumes(MediaType.APPLICATION_JSON) @Path("/artifact") @Timed @UnitOfWork @ApiOperation(value = "Registers a processor/source jar from artifactory", response = List.class) Response registerFromArtifactory(@Context UriInfo uriinfo,
            @NotNull final ArtifactoryRegistrationRequest request);  }### Answer:
@Test public void testGetByVersion() { doReturn(component).when(service).get(2); final Response response = resource.get(2); Assert.assertEquals(response.getStatus(), 200); Assert.assertEquals(response.getEntity(), component); }
@Test public void testGet() { doReturn(ImmutableSet.of(component)).when(service).search(anyString(), anyString(), anyString()); final Response response = resource.get(component.getNamespace(), component.getName(), component.getVersion()); Assert.assertEquals(response.getStatus(), 200); Assert.assertEquals(response.getEntity(), component); }