@Before public void setUp() { LocalizerServiceStub localizerServiceStub = new LocalizerServiceStub() { @Override public String getLocalizedTextFromDatabase( String localeString, long objectKey, LocalizedObjectTypes objectType) { return localizedText; } }; facade = new LocalizerFacade(localizerServiceStub, Locale.GERMAN.getLanguage()); // server side entries Product product = new Product(); product.setKey(PRODUCT_KEY); product.setTechnicalProduct(new TechnicalProduct()); product.setAutoAssignUserEnabled(false); ProductFeedback feedback = new ProductFeedback(); feedback.setAverageRating(new BigDecimal("2.5")); product.setProductFeedback(feedback); mp = new Marketplace(); mp.setKey(1); mp.setMarketplaceId(MP_ID); mp.setOrganization(new Organization()); catalogEntry = new CatalogEntry(); catalogEntry.setKey(1); catalogEntry.setProduct(product); catalogEntry.setMarketplace(mp); catalogEntry.setAnonymousVisible(true); catalogEntry.setVisibleInCatalog(true); catalogEntry2 = new CatalogEntry(); catalogEntry2.setKey(2); catalogEntry3 = new CatalogEntry(); catalogEntry3.setKey(3); VOMarketplace voMp = new VOMarketplace(); voMp.setMarketplaceId(MP_ID); // incoming entries voCatalogEntry = new VOCatalogEntry(); voCatalogEntry.setKey(1); voCatalogEntry.setVersion(0); voCatalogEntry.setMarketplace(voMp); voCatalogEntry.setAnonymousVisible(true); voCatalogEntry.setVisibleInCatalog(true); voCatalogEntry2 = new VOCatalogEntry(); voCatalogEntry2.setKey(2); voCatalogEntry3 = new VOCatalogEntry(); voCatalogEntry3.setKey(3); }
@Test(expected = ConcurrentModificationException.class) public void consolidateCatalogEntries_WrongVersion() throws Exception { voCatalogEntry.setVersion(-1); CatalogEntryAssembler.consolidateCatalogEntries( Collections.singleton(voCatalogEntry), Arrays.asList(catalogEntry)); }
@Test(expected = ConcurrentModificationException.class) public void updateCatalogEntry_conflictingVersions() throws Exception { voCatalogEntry.setVersion(-1); CatalogEntryAssembler.updateCatalogEntry(catalogEntry, voCatalogEntry); }