### Question:
DBBaselineManager extends DBManager<Baseline> implements BaselineManager { @Override public final void updateBaseline(final Baseline baseline) throws BaselineManagerException { LOGGER.debug("updating baseline: {}", baseline); try { super.update(baseline); } catch (DBManagerException e) { throw new BaselineManagerException(e); } } DBBaselineManager(final SessionFactory sessionFactory); @Override final Baseline saveBaseline(final Baseline baseline); @Override final void updateBaseline(final Baseline baseline); @Override final List<Baseline> getBaselineList(final Class<? extends Baseline> clazz); @Override final FilteredRecordsList<Baseline> getOrderedBaselineList(
            final String columnToOrder, final boolean ascending,
            final int firstResult, final int maxResults, final String search,
            final Map<String, Boolean> searchableColumns); @Override final FilteredRecordsList<IMABaselineRecord> getOrderedRecordList(
            final UUID baselineId, final String columnToOrder, final boolean ascending,
            final int firstResult, final int maxResults, final String search); @Override final FilteredRecordsList<ImaBlacklistRecord> getOrderedBlacklistRecordList(
            final UUID baselineId, final String columnToOrder, final boolean ascending,
            final int firstResult, final int maxResults, final String search); @Override final FilteredRecordsList<RepoPackage> getOrderedPackageList(
            final String name, final String columnToOrder, final boolean ascending,
            final int firstResult, final int maxResults, final String search); @Override List<IMABaselineRecord> getPackageRecords(final UUID id, final String search); @Override final Baseline getBaseline(final String name); @Override final Baseline getBaseline(final Serializable id); @Override final Baseline getCompleteBaseline(final String name); @Override final FilteredRecordsList<SimpleBaselineBean> getOrderedBaselineListWithoutRecords(
            final String columnToOrder, final boolean ascending,
            final int firstResult, final int maxResults, final String search,
            final Map<String, Boolean> searchableColumns);  }### Answer:
@Test public void testUpdate() throws BaselineManagerException { LOGGER.debug("testUpdate test started"); final String updatedName = "Updated Baseline"; final BaselineManager mgr = new DBBaselineManager(sessionFactory); final Baseline baseline = createBaseline(mgr); baseline.setName(updatedName); mgr.updateBaseline(baseline); Assert.assertTrue(isInDatabase(updatedName, sessionFactory)); Assert.assertFalse(isInDatabase(BASELINE_NAME, sessionFactory)); }
@Test public void testUpdateSameName() throws BaselineManagerException { LOGGER.debug("testUpdateSameName test started"); final String name1 = "Test Baseline 1"; final String name2 = "Test Baseline 2"; final BaselineManager mgr = new DBBaselineManager(sessionFactory); createBaseline(mgr, name1); final Baseline b2 = createBaseline(mgr, name2); b2.setName(name1); BaselineManagerException expected = null; try { mgr.updateBaseline(b2); } catch (BaselineManagerException e) { expected = e; } Assert.assertNotNull(expected); Assert.assertTrue(isInDatabase(name1, sessionFactory)); Assert.assertTrue(isInDatabase(name2, sessionFactory)); }
@Test(expectedExceptions = NullPointerException.class) public void testUpdateNullBaseline() throws BaselineManagerException { LOGGER.debug("testUpdateNullBaseline test started"); final BaselineManager mgr = new DBBaselineManager(sessionFactory); mgr.updateBaseline(null); Assert.fail("save did not fail"); }