@Test( description = "PUT /admin/catalog/{id}", dependsOnMethods = {"testGetCatalogOwner"}) public void testEditCatalog() { String oldName = catalog.getName(); String newName = "new " + oldName; String oldDescription = catalog.getDescription(); String newDescription = "new " + oldDescription; // TODO: can we edit/manage catalogItems directly like this? or does it just do a merge // (like metadata) // CatalogItems oldCatalogItems = catalog.getCatalogItems(); // CatalogItems newCatalogItems = CatalogItems.builder().build(); try { catalog = catalog .toBuilder() .name(newName) .description(newDescription) // .catalogItems(newCatalogItems) .build(); catalog = catalogApi.edit(catalog.getId(), catalog); assertTrue( equal(catalog.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, CATALOG, "name")); assertTrue( equal(catalog.getDescription(), newDescription), String.format(OBJ_FIELD_UPDATABLE, CATALOG, "description")); // assertTrue(equal(catalog.getCatalogItems(), newCatalogItems), // String.format(OBJ_FIELD_UPDATABLE, CATALOG, "catalogItems")); // TODO negative tests? Checks.checkAdminCatalog(catalog); } finally { catalog = catalog .toBuilder() .name(oldName) .description(oldDescription) // .catalogItems(oldCatalogItems) .build(); catalog = catalogApi.edit(catalog.getId(), catalog); } }
@AfterClass(alwaysRun = true) protected void tidyUp() { if (catalog != null) { try { catalogApi.remove(catalog.getId()); } catch (Exception e) { logger.warn(e, "Error deleting admin catalog '%s'", catalog.getName()); } } }