Search in sources :

Example 1 with ModelTranslator

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);
}
Also used : Owner(org.candlepin.model.Owner) ArrayList(java.util.ArrayList) CandlepinQuery(org.candlepin.model.CandlepinQuery) ConsumerTypeValidator(org.candlepin.resource.util.ConsumerTypeValidator) Consumer(org.candlepin.model.Consumer) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) ArrayList(java.util.ArrayList) List(java.util.List) ModelTranslator(org.candlepin.dto.ModelTranslator) ConsumerType(org.candlepin.model.ConsumerType) Test(org.junit.Test)

Example 2 with ModelTranslator

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);
}
Also used : Owner(org.candlepin.model.Owner) ArrayList(java.util.ArrayList) CandlepinQuery(org.candlepin.model.CandlepinQuery) Matchers.anyString(org.mockito.Matchers.anyString) ConsumerTypeValidator(org.candlepin.resource.util.ConsumerTypeValidator) Consumer(org.candlepin.model.Consumer) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) ArrayList(java.util.ArrayList) List(java.util.List) ModelTranslator(org.candlepin.dto.ModelTranslator) ConsumerType(org.candlepin.model.ConsumerType) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 ModelTranslator (org.candlepin.dto.ModelTranslator)2 ConsumerDTO (org.candlepin.dto.api.v1.ConsumerDTO)2 CandlepinQuery (org.candlepin.model.CandlepinQuery)2 Consumer (org.candlepin.model.Consumer)2 ConsumerType (org.candlepin.model.ConsumerType)2 Owner (org.candlepin.model.Owner)2 ConsumerTypeValidator (org.candlepin.resource.util.ConsumerTypeValidator)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)1