@Test
 public void updateCatalogEntry_updateAnoymousVisible() throws Exception {
   Assert.assertEquals(voCatalogEntry.isAnonymousVisible(), catalogEntry.isAnonymousVisible());
   voCatalogEntry.setAnonymousVisible(!catalogEntry.isAnonymousVisible());
   assertFalse(voCatalogEntry.isAnonymousVisible() == catalogEntry.isAnonymousVisible());
   CatalogEntry entry = CatalogEntryAssembler.updateCatalogEntry(catalogEntry, voCatalogEntry);
   Assert.assertEquals(voCatalogEntry.isAnonymousVisible(), entry.isAnonymousVisible());
 }
  @Test
  public void toCatalogEntry() throws ValidationException {
    // given
    VOService service = new VOService();
    service.setServiceId("sId");
    voCatalogEntry.setService(service);

    // when
    CatalogEntry ce = CatalogEntryAssembler.toCatalogEntry(voCatalogEntry);

    // then
    assertEquals(voCatalogEntry.getKey(), ce.getKey());
    assertEquals(voCatalogEntry.isAnonymousVisible(), ce.isAnonymousVisible());
    assertEquals(voCatalogEntry.isVisibleInCatalog(), ce.isVisibleInCatalog());
    assertNotNull(ce.getMarketplace());
    assertEquals(
        voCatalogEntry.getMarketplace().getMarketplaceId(), ce.getMarketplace().getMarketplaceId());
  }
  /** domain object -> value object */
  @Test
  public void toVOCatalogEntry() {

    List<CategoryToCatalogEntry> categoryToCatalogEntry = new ArrayList<CategoryToCatalogEntry>();
    CategoryToCatalogEntry ctc = new CategoryToCatalogEntry();
    ctc.setCatalogEntry(catalogEntry);
    Category category = new Category();
    category.setCategoryId("categoryId");
    category.setMarketplaceKey(mp.getKey());
    category.setMarketplace(mp);
    category.setKey(3333);
    ctc.setCategory(category);
    ctc.setKey(2222);
    categoryToCatalogEntry.add(ctc);
    catalogEntry.setCategoryToCatalogEntry(categoryToCatalogEntry);
    catalogEntry.getProduct().setVendor(new Organization());

    VOCatalogEntry voEntry = CatalogEntryAssembler.toVOCatalogEntry(catalogEntry, facade);
    assertNotNull(voEntry);
    assertEquals(catalogEntry.getKey(), voEntry.getKey());
    assertEquals(catalogEntry.getProduct().getKey(), voEntry.getService().getKey());
    assertEquals(catalogEntry.getVersion(), voEntry.getVersion());
    Assert.assertEquals(catalogEntry.isAnonymousVisible(), voEntry.isAnonymousVisible());
    Assert.assertEquals(catalogEntry.isVisibleInCatalog(), voEntry.isVisibleInCatalog());
    if (catalogEntry.getMarketplace() != null || voEntry.getMarketplace() != null) {
      assertNotNull(catalogEntry.getMarketplace());
      assertNotNull(voEntry.getMarketplace());
      assertEquals(
          catalogEntry.getMarketplace().getMarketplaceId(),
          voEntry.getMarketplace().getMarketplaceId());
    }

    assertNotNull(voEntry.getCategories());
    assertEquals(1, voEntry.getCategories().size());
    assertEquals(category.getCategoryId(), voEntry.getCategories().get(0).getCategoryId());
  }