use of org.candlepin.dto.api.v1.UpstreamConsumerDTO in project candlepin by candlepin.
the class OwnerResourceTest method upstreamConsumers.
@Test
public void upstreamConsumers() {
Principal p = mock(Principal.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
UpstreamConsumer upstream = mock(UpstreamConsumer.class);
Owner owner = mock(Owner.class);
OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
when(oc.lookupByKey(eq("admin"))).thenReturn(owner);
when(owner.getUpstreamConsumer()).thenReturn(upstream);
List<UpstreamConsumerDTO> results = ownerres.getUpstreamConsumers(p, "admin");
assertNotNull(results);
assertEquals(1, results.size());
}
use of org.candlepin.dto.api.v1.UpstreamConsumerDTO in project candlepin by candlepin.
the class OwnerResource method getUpstreamConsumers.
/**
* Retrieves a list of Upstream Consumers for an Owner
*
* @return a list of UpstreamConsumer objects
* @httpcode 404
* @httpcode 200
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{owner_key}/upstream_consumers")
@ApiOperation(notes = " Retrieves a list of Upstream Consumers for an Owner", value = "Get Upstream Consumers")
@ApiResponses({ @ApiResponse(code = 404, message = "Owner not found") })
public List<UpstreamConsumerDTO> getUpstreamConsumers(@Context Principal principal, @Verify(Owner.class) @PathParam("owner_key") String ownerKey) {
Owner owner = this.findOwnerByKey(ownerKey);
UpstreamConsumer consumer = owner.getUpstreamConsumer();
UpstreamConsumerDTO dto = this.translator.translate(consumer, UpstreamConsumerDTO.class);
// when multiples are supported.
return Arrays.asList(dto);
}
Aggregations