### Question:
DBBaselineManager extends DBManager<Baseline> implements BaselineManager { @Override public final Baseline saveBaseline(final Baseline baseline) throws BaselineManagerException { LOGGER.debug("saving baseline: {}", baseline); try { return super.save(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 testSave() throws BaselineManagerException { LOGGER.debug("testSave test started"); final TestBaseline baseline = new TestBaseline(BASELINE_NAME); final BaselineManager mgr = new DBBaselineManager(sessionFactory); final TestBaseline b2 = (TestBaseline) mgr.saveBaseline(baseline); Assert.assertEquals(b2, baseline); Assert.assertTrue(isInDatabase(BASELINE_NAME, sessionFactory)); }
@Test(expectedExceptions = BaselineManagerException.class) public void testSaveTwice() throws BaselineManagerException { LOGGER.debug("testSaveTwice test started"); final TestBaseline baseline = new TestBaseline(BASELINE_NAME); final BaselineManager mgr = new DBBaselineManager(sessionFactory); final TestBaseline b2 = (TestBaseline) mgr.saveBaseline(baseline); mgr.saveBaseline(b2); Assert.fail("second save did not fail"); }
@Test(expectedExceptions = BaselineManagerException.class) public void testSaveSameName() throws BaselineManagerException { LOGGER.debug("testSaveSameName test started"); final TestBaseline baseline = new TestBaseline(BASELINE_NAME); final TestBaseline baseline2 = new TestBaseline(BASELINE_NAME); final BaselineManager mgr = new DBBaselineManager(sessionFactory); final TestBaseline b2 = (TestBaseline) mgr.saveBaseline(baseline); Assert.assertNotNull(b2); mgr.saveBaseline(baseline2); Assert.fail("second save did not fail"); }
@Test(expectedExceptions = NullPointerException.class) public void testSaveNullBaseline() throws BaselineManagerException { LOGGER.debug("testSaveNullBaseline test started"); final BaselineManager mgr = new DBBaselineManager(sessionFactory); mgr.saveBaseline(null); Assert.fail("save did not fail"); }