use of org.candlepin.dto.ModelTranslator in project candlepin by candlepin.
the class ConsumerResourceTest method testFetchAllConsumersForUser.
@Test
public void testFetchAllConsumersForUser() {
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<ConsumerDTO> result = cr.list("TaylorSwift", null, null, null, null, null, null).list();
assertEquals(consumers, result);
}
use of org.candlepin.dto.ModelTranslator 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);
}
Aggregations