use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class ImporterTest method testImportNoProductDir.
@Test
public void testImportNoProductDir() throws IOException, ImporterException {
RulesImporter ri = mock(RulesImporter.class);
OwnerCurator oc = mock(OwnerCurator.class);
Importer i = new Importer(null, null, ri, oc, null, null, null, null, config, null, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
Owner owner = mock(Owner.class);
ConflictOverrides co = mock(ConflictOverrides.class);
Map<String, File> importFiles = getTestImportFiles();
File ruleDir = mock(File.class);
File[] rulesFiles = createMockJsFile(mockJsPath);
when(ruleDir.listFiles()).thenReturn(rulesFiles);
File actualmeta = createFile("meta.json", "0.0.3", new Date(), "test_user", "prefix");
// this is the hook to stop testing. we confirm that the archive component tests
// are passed and then jump out instead of trying to fake the actual file
// processing.
doThrow(new RuntimeException("Done with the test")).when(ri).importObject(any(Reader.class));
importFiles.put(ImportFile.META.fileName(), actualmeta);
importFiles.put(ImportFile.RULES_FILE.fileName(), rulesFiles[0]);
importFiles.put(ImportFile.PRODUCTS.fileName(), null);
importFiles.put(ImportFile.ENTITLEMENTS.fileName(), null);
importFiles.put(ImportFile.UPSTREAM_CONSUMER.fileName(), mock(File.class));
ee.expect(RuntimeException.class);
ee.expectMessage("Done with the test");
i.importObjects(owner, importFiles, co);
}
use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class ImporterTest method testImportProductNoEntitlementDir.
@Test
public void testImportProductNoEntitlementDir() throws IOException, ImporterException {
OwnerCurator oc = mock(OwnerCurator.class);
Importer i = new Importer(null, null, null, oc, null, null, null, null, config, null, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
Owner owner = mock(Owner.class);
ConflictOverrides co = mock(ConflictOverrides.class);
Map<String, File> importFiles = getTestImportFiles();
importFiles.put(ImportFile.ENTITLEMENTS.fileName(), null);
String m = i18n.tr("The archive does not contain the " + "required entitlements directory");
ee.expect(ImporterException.class);
ee.expectMessage(m);
i.importObjects(owner, importFiles, co);
}
use of org.candlepin.model.OwnerCurator 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.OwnerCurator 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.OwnerCurator in project candlepin by candlepin.
the class OwnerProductResourceTest method testDeleteProductWithSubscriptions.
@Test(expected = BadRequestException.class)
public void testDeleteProductWithSubscriptions() {
OwnerCurator oc = mock(OwnerCurator.class);
OwnerProductCurator opc = mock(OwnerProductCurator.class);
ProductCurator pc = mock(ProductCurator.class);
I18n i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
OwnerProductResource pr = new OwnerProductResource(config, i18n, oc, null, opc, null, pc, null, this.modelTranslator);
Owner o = mock(Owner.class);
Product p = mock(Product.class);
when(oc.lookupByKey(eq("owner"))).thenReturn(o);
when(opc.getProductById(eq(o), eq("10"))).thenReturn(p);
Set<Subscription> subs = new HashSet<>();
Subscription s = mock(Subscription.class);
subs.add(s);
when(pc.productHasSubscriptions(eq(o), eq(p))).thenReturn(true);
pr.deleteProduct("owner", "10");
}
Aggregations