private DefaultVersionedCatalog getCatalog(final boolean useDefaultCatalog, final boolean filterTemplateCatalog, final boolean internalUse, final InternalTenantContext context) throws CatalogApiException { return catalogCache.getCatalog(useDefaultCatalog, filterTemplateCatalog, internalUse, context); } }
@Test(groups = "fast") public void testMissingDefaultCatalog() throws CatalogApiException { catalogCache.loadDefaultCatalog(null); Assert.assertEquals(catalogCache.getCatalog(true, true, false, internalCallContext).getCatalogName(), "EmptyCatalog"); }
VersionedCatalog differentResult = catalogCache.getCatalog(true, true, false, differentMultiTenantContext); Assert.assertNotNull(differentResult); Assert.assertEquals(differentResult.getCatalogName(), "EmptyCatalog"); differentResult = catalogCache.getCatalog(true, true, false, differentMultiTenantContext); Assert.assertNotNull(differentResult); Assert.assertEquals(differentResult.getCatalogName(), "EmptyCatalog"); final DefaultVersionedCatalog result = catalogCache.getCatalog(true, true, false, multiTenantContext); Assert.assertNotNull(result); final Collection<Product> products = result.getProducts(clock.getUTCNow()); final DefaultVersionedCatalog otherResult = catalogCache.getCatalog(true, true, false, otherMultiTenantContext); Assert.assertNotNull(otherResult); final Collection<Product> otherProducts = otherResult.getProducts(clock.getUTCNow()); final VersionedCatalog result2 = catalogCache.getCatalog(true, true, false, multiTenantContext); Assert.assertEquals(result2, result); Mockito.when(sameMultiTenantContext.getAccountRecordId()).thenReturn(9102L); Mockito.when(sameMultiTenantContext.getTenantRecordId()).thenReturn(multiTenantRecordId); Assert.assertEquals(catalogCache.getCatalog(true, true, false, sameMultiTenantContext), result); Assert.assertEquals(catalogCache.getCatalog(true, true, false, otherMultiTenantContext), otherResult);
@Test(groups = "fast") public void testDefaultCatalog() throws CatalogApiException { catalogCache.loadDefaultCatalog(Resources.getResource("SpyCarBasic.xml").toExternalForm()); final DefaultVersionedCatalog result = catalogCache.getCatalog(true, true, false, internalCallContext); Assert.assertNotNull(result); final Collection<Product> products = result.getProducts(clock.getUTCNow()); Assert.assertEquals(products.size(), 3); // Verify the lookup with other contexts final DefaultVersionedCatalog resultForMultiTenantContext = new DefaultVersionedCatalog(result.getClock()); for (final StandaloneCatalog cur : result.getVersions()) { resultForMultiTenantContext.add(new StandaloneCatalogWithPriceOverride(cur, priceOverride, multiTenantContext.getTenantRecordId(), internalCallContextFactory)); } Assert.assertEquals(catalogCache.getCatalog(true, true, false, multiTenantContext).getCatalogName(), resultForMultiTenantContext.getCatalogName()); Assert.assertEquals(catalogCache.getCatalog(true, true, false, multiTenantContext).getVersions().size(), resultForMultiTenantContext.getVersions().size()); for (int i = 0; i < catalogCache.getCatalog(true, true, false, multiTenantContext).getVersions().size(); i++) { Assert.assertEquals(((StandaloneCatalogWithPriceOverride) catalogCache.getCatalog(true, true, false, multiTenantContext).getVersions().get(i)).getTenantRecordId(), ((StandaloneCatalogWithPriceOverride) resultForMultiTenantContext.getVersions().get(i)).getTenantRecordId()); } }
private DefaultVersionedCatalog getCatalog(final boolean useDefaultCatalog, final boolean filterTemplateCatalog, final boolean internalUse, final InternalTenantContext context) throws CatalogApiException { return catalogCache.getCatalog(useDefaultCatalog, filterTemplateCatalog, internalUse, context); } }
@Test(groups = "fast") public void testMissingDefaultCatalog() throws CatalogApiException { catalogCache.loadDefaultCatalog(null); Assert.assertEquals(catalogCache.getCatalog(true, true, false, internalCallContext).getCatalogName(), "EmptyCatalog"); }
@Test(groups = "fast") public void testDefaultCatalog() throws CatalogApiException { catalogCache.loadDefaultCatalog(Resources.getResource("SpyCarBasic.xml").toExternalForm()); final DefaultVersionedCatalog result = catalogCache.getCatalog(true, true, false, internalCallContext); Assert.assertNotNull(result); final Collection<Product> products = result.getProducts(clock.getUTCNow()); Assert.assertEquals(products.size(), 3); // Verify the lookup with other contexts final DefaultVersionedCatalog resultForMultiTenantContext = new DefaultVersionedCatalog(result.getClock()); for (final StandaloneCatalog cur : result.getVersions()) { resultForMultiTenantContext.add(new StandaloneCatalogWithPriceOverride(cur, priceOverride, multiTenantContext.getTenantRecordId(), internalCallContextFactory)); } Assert.assertEquals(catalogCache.getCatalog(true, true, false, multiTenantContext).getCatalogName(), resultForMultiTenantContext.getCatalogName()); Assert.assertEquals(catalogCache.getCatalog(true, true, false, multiTenantContext).getVersions().size(), resultForMultiTenantContext.getVersions().size()); for (int i = 0; i < catalogCache.getCatalog(true, true, false, multiTenantContext).getVersions().size(); i++) { Assert.assertEquals(((StandaloneCatalogWithPriceOverride) catalogCache.getCatalog(true, true, false, multiTenantContext).getVersions().get(i)).getTenantRecordId(), ((StandaloneCatalogWithPriceOverride) resultForMultiTenantContext.getVersions().get(i)).getTenantRecordId()); } }
VersionedCatalog differentResult = catalogCache.getCatalog(true, true, false, differentMultiTenantContext); Assert.assertNotNull(differentResult); Assert.assertEquals(differentResult.getCatalogName(), "EmptyCatalog"); differentResult = catalogCache.getCatalog(true, true, false, differentMultiTenantContext); Assert.assertNotNull(differentResult); Assert.assertEquals(differentResult.getCatalogName(), "EmptyCatalog"); final DefaultVersionedCatalog result = catalogCache.getCatalog(true, true, false, multiTenantContext); Assert.assertNotNull(result); final Collection<Product> products = result.getProducts(clock.getUTCNow()); final DefaultVersionedCatalog otherResult = catalogCache.getCatalog(true, true, false, otherMultiTenantContext); Assert.assertNotNull(otherResult); final Collection<Product> otherProducts = otherResult.getProducts(clock.getUTCNow()); final VersionedCatalog result2 = catalogCache.getCatalog(true, true, false, multiTenantContext); Assert.assertEquals(result2, result); Mockito.when(sameMultiTenantContext.getAccountRecordId()).thenReturn(9102L); Mockito.when(sameMultiTenantContext.getTenantRecordId()).thenReturn(multiTenantRecordId); Assert.assertEquals(catalogCache.getCatalog(true, true, false, sameMultiTenantContext), result); Assert.assertEquals(catalogCache.getCatalog(true, true, false, otherMultiTenantContext), otherResult);