use of org.candlepin.model.CandlepinQuery in project candlepin by candlepin.
the class ConsumerResourceTest method testFetchAllConsumersForSomeUUIDs.
@Test
public void testFetchAllConsumersForSomeUUIDs() {
ModelTranslator mockTranslator = mock(ModelTranslator.class);
ConsumerResource cr = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, null, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.config, null, null, null, null, null, null, this.factValidator, new ConsumerTypeValidator(null, null), consumerEnricher, migrationProvider, mockTranslator);
ArrayList<Consumer> consumers = new ArrayList<>();
CandlepinQuery cqmock = mock(CandlepinQuery.class);
when(cqmock.list()).thenReturn(consumers);
when(cqmock.iterator()).thenReturn(consumers.iterator());
when(mockConsumerCurator.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))).thenReturn(cqmock);
when(mockTranslator.translateQuery(eq(cqmock), eq(ConsumerDTO.class))).thenReturn(cqmock);
List<String> uuids = new ArrayList<>();
uuids.add("swiftuuid");
List<ConsumerDTO> result = cr.list(null, null, null, uuids, null, null, null).list();
assertEquals(consumers, result);
}
use of org.candlepin.model.CandlepinQuery in project candlepin by candlepin.
the class ContentResourceTest method getContent.
@Test
public void getContent() {
Owner owner = mock(Owner.class);
Content content = mock(Content.class);
CandlepinQuery cqmock = mock(CandlepinQuery.class);
ContentDTO expected = this.modelTranslator.translate(content, ContentDTO.class);
when(cqmock.list()).thenReturn(Arrays.asList(owner));
when(oc.listAll()).thenReturn(cqmock);
when(cc.lookupByUuid(eq("10"))).thenReturn(content);
ContentDTO output = cr.getContent("10");
assertEquals(expected, output);
}
use of org.candlepin.model.CandlepinQuery in project candlepin by candlepin.
the class EventResourceTest method testListEvents.
@Test
public void testListEvents() {
EventResource er = new EventResource(ec, null, injector.getInstance(EventAdapter.class), translator);
CandlepinQuery cpQueryMock = mock(CandlepinQuery.class);
List<Event> events = new ArrayList<>();
events.add(getEvent());
List<EventDTO> eventDTOs = new ArrayList<>();
eventDTOs.add(getEventDTO());
when(ec.listAll()).thenReturn(cpQueryMock);
when(cpQueryMock.list()).thenReturn(events);
when(translator.translate(any(Event.class), any(Class.class))).thenReturn(getEventDTO());
assertEquals(eventDTOs, er.listEvents());
}
use of org.candlepin.model.CandlepinQuery in project candlepin by candlepin.
the class CertificateSerialResourceTest method listall.
@Test
public void listall() {
CandlepinQuery cqmock = new EmptyCandlepinQuery();
CertificateSerialCurator csc = mock(CertificateSerialCurator.class);
when(csc.listAll()).thenReturn(cqmock);
CertificateSerialResource csr = new CertificateSerialResource(csc, this.modelTranslator);
CandlepinQuery<CertificateSerialDTO> result = csr.getCertificateSerials();
assertNotNull(result);
verify(csc, times(1)).listAll();
}
use of org.candlepin.model.CandlepinQuery in project candlepin by candlepin.
the class InstalledProductStatusCalculatorTest method mockConsumerEntitlements.
private void mockConsumerEntitlements(Consumer consumer, Collection<Entitlement> entitlements) {
List<Entitlement> entList = new LinkedList(entitlements);
CandlepinQuery mockCPQuery = mock(CandlepinQuery.class);
when(mockCPQuery.list()).thenReturn(entList);
when(mockCPQuery.iterator()).thenReturn(entitlements.iterator());
when(entCurator.listByConsumer(eq(consumer))).thenReturn(entList);
when(entCurator.listByConsumerAndDate(eq(consumer), any(Date.class))).thenReturn(mockCPQuery);
}
Aggregations