use of org.candlepin.model.ConsumerTypeCurator in project candlepin by candlepin.
the class ConsumerTypeImporterTest method testSingleConsumerTypeInDbAndListCausesNoChange.
@Test
public void testSingleConsumerTypeInDbAndListCausesNoChange() {
final ConsumerType testType = new ConsumerType();
testType.setLabel("prosumer");
ConsumerTypeCurator curator = mock(ConsumerTypeCurator.class);
when(curator.lookupByLabel("prosumer")).thenReturn(testType);
ConsumerTypeImporter importer = new ConsumerTypeImporter(curator);
importer.store(new HashSet<ConsumerType>() {
{
add(testType);
}
});
verify(curator, never()).create(testType);
verify(curator, never()).merge(testType);
}
use of org.candlepin.model.ConsumerTypeCurator in project candlepin by candlepin.
the class HypervisorUpdateJobTest method init.
@Before
public void init() {
super.init();
i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.READ_PROPERTIES | I18nFactory.FALLBACK);
owner = mock(Owner.class);
principal = mock(Principal.class);
ownerCurator = mock(OwnerCurator.class);
consumerCurator = mock(ConsumerCurator.class);
consumerResource = mock(ConsumerResource.class);
consumerTypeCurator = mock(ConsumerTypeCurator.class);
subAdapter = mock(SubscriptionServiceAdapter.class);
complianceRules = mock(ComplianceRules.class);
when(owner.getId()).thenReturn("joe");
ConsumerType ctype = new ConsumerType(ConsumerTypeEnum.HYPERVISOR);
ctype.setId("test-ctype");
when(consumerTypeCurator.lookupByLabel(eq(ConsumerTypeEnum.HYPERVISOR.getLabel()))).thenReturn(ctype);
when(consumerTypeCurator.lookupByLabel(eq(ConsumerTypeEnum.HYPERVISOR.getLabel()), anyBoolean())).thenReturn(ctype);
when(owner.getKey()).thenReturn("joe");
when(principal.getUsername()).thenReturn("joe user");
testMigration = new GuestMigration(consumerCurator);
migrationProvider = Providers.of(testMigration);
hypervisorJson = "{\"hypervisors\":" + "[{" + "\"name\" : \"hypervisor_999\"," + "\"hypervisorId\" : {\"hypervisorId\":\"uuid_999\"}," + "\"guestIds\" : [{\"guestId\" : \"guestId_1_999\"}]" + "}]}";
}
use of org.candlepin.model.ConsumerTypeCurator in project candlepin by candlepin.
the class ProductExporterTest method testProductExport.
@Test
public void testProductExport() throws IOException {
ObjectMapper mapper = TestSyncUtils.getTestSyncUtils(new MapConfiguration(new HashMap<String, String>() {
{
put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES, "false");
}
}));
ProductExporter exporter = new ProductExporter(new StandardTranslator(new ConsumerTypeCurator(), new EnvironmentCurator(), new OwnerCurator()));
StringWriter writer = new StringWriter();
Owner owner = TestUtil.createOwner("Example-Corporation");
Product product = TestUtil.createProduct("my-id", "product name");
exporter.export(mapper, writer, product);
String s = writer.toString();
assertTrue(s.contains("\"name\":\"product name\""));
assertTrue(s.contains("\"id\":\"my-id\""));
assertTrue(s.contains("\"productContent\":[]"));
assertTrue(s.contains("\"attributes\":[]"));
assertTrue(s.contains("\"multiplier\":1"));
}
use of org.candlepin.model.ConsumerTypeCurator in project candlepin by candlepin.
the class SubscriptionReconcilerTest method init.
@Before
public void init() {
this.owner = new Owner();
this.reconciler = new SubscriptionReconciler(this.poolCurator);
this.translator = new StandardTranslator(new ConsumerTypeCurator(), new EnvironmentCurator(), new OwnerCurator());
i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
this.importer = new EntitlementImporter(certSerialCurator, cdnCurator, i18n, pc, ec, translator);
}
use of org.candlepin.model.ConsumerTypeCurator in project candlepin by candlepin.
the class ConsumerTypeImporterTest method testSingleConsumerTypeInListEmptyDbCausesInsert.
@Test
public void testSingleConsumerTypeInListEmptyDbCausesInsert() {
final ConsumerType testType = new ConsumerType();
testType.setLabel("prosumer");
ConsumerTypeCurator curator = mock(ConsumerTypeCurator.class);
when(curator.lookupByLabel("prosumer")).thenReturn(null);
ConsumerTypeImporter importer = new ConsumerTypeImporter(curator);
importer.store(new HashSet<ConsumerType>() {
{
add(testType);
}
});
verify(curator).create(testType);
verify(curator, never()).merge(testType);
}
Aggregations