Exemplo n.º 1
0
 @Test
 public void testFetchAllConsumersForSomeUUIDs() {
   ConsumerResource cr =
       new ConsumerResource(
           mockedConsumerCurator,
           null,
           null,
           null,
           null,
           null,
           null,
           i18n,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           new CandlepinCommonTestConfig(),
           null,
           null,
           null,
           null,
           productCurator,
           null);
   Page<List<Consumer>> page = new Page<List<Consumer>>();
   ArrayList<Consumer> consumers = new ArrayList<Consumer>();
   page.setPageData(consumers);
   when(mockedConsumerCurator.searchOwnerConsumers(
           any(Owner.class),
           anyString(),
           (java.util.Collection<ConsumerType>) any(Collection.class),
           any(List.class),
           any(List.class),
           any(List.class),
           any(List.class),
           any(List.class),
           any(List.class),
           any(PageRequest.class)))
       .thenReturn(page);
   List<String> uuids = new ArrayList<String>();
   uuids.add("swiftuuid");
   List<Consumer> result = cr.list(null, null, null, uuids, null, null, null);
   assertEquals(consumers, result);
 }
Exemplo n.º 2
0
  public void testFetchAllConsumersForOwner() {
    ConsumerResource cr =
        new ConsumerResource(
            mockedConsumerCurator,
            null,
            null,
            null,
            null,
            null,
            null,
            i18n,
            null,
            null,
            null,
            null,
            null,
            null,
            null,
            mockedOwnerCurator,
            null,
            null,
            null,
            null,
            null,
            null,
            new CandlepinCommonTestConfig(),
            null,
            null,
            null,
            null,
            productCurator,
            null);
    Page<List<Consumer>> page = new Page<List<Consumer>>();
    ArrayList<Consumer> consumers = new ArrayList<Consumer>();
    page.setPageData(consumers);

    when(mockedOwnerCurator.lookupByKey(eq("taylorOwner"))).thenReturn(new Owner());
    when(mockedConsumerCurator.searchOwnerConsumers(
            any(Owner.class),
            anyString(),
            (java.util.Collection<ConsumerType>) any(Collection.class),
            any(List.class),
            any(List.class),
            any(List.class),
            any(List.class),
            any(List.class),
            any(List.class),
            any(PageRequest.class)))
        .thenReturn(page);
    List<Consumer> result = cr.list(null, null, "taylorOwner", null, null, null, null);
    assertEquals(consumers, result);
  }