/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.masterdb.historicaltimeseries;
import static org.testng.AssertJUnit.assertEquals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.threeten.bp.Instant;
import com.opengamma.DataNotFoundException;
import com.opengamma.id.ObjectId;
import com.opengamma.id.UniqueId;
import com.opengamma.master.historicaltimeseries.HistoricalTimeSeriesInfoDocument;
import com.opengamma.util.test.DbTest;
import com.opengamma.util.test.TestGroup;
/**
* Tests DbHistoricalTimeSeriesMaster.
*/
@Test(groups = TestGroup.UNIT_DB)
public class DbHistoricalTimeSeriesMasterWorkerRemoveTest extends AbstractDbHistoricalTimeSeriesMasterWorkerTest {
// superclass sets up dummy database
private static final Logger s_logger = LoggerFactory.getLogger(DbHistoricalTimeSeriesMasterWorkerRemoveTest.class);
@Factory(dataProvider = "databases", dataProviderClass = DbTest.class)
public DbHistoricalTimeSeriesMasterWorkerRemoveTest(String databaseType, String databaseVersion) {
super(databaseType, databaseVersion);
s_logger.info("running testcases for {}", databaseType);
}
//-------------------------------------------------------------------------
@Test(expectedExceptions = DataNotFoundException.class)
public void test_removeHistoricalTimeSeries_versioned_notFoundId() {
UniqueId uniqueId = UniqueId.of("DbHts", "0", "0");
_htsMaster.remove(uniqueId);
}
@Test(expectedExceptions = DataNotFoundException.class)
public void test_removeHistoricalTimeSeries_versioned_notFoundVersion() {
ObjectId objectId = ObjectId.of("DbHts", "6666666666");
_htsMaster.remove(objectId);
}
@Test
public void test_removeHistoricalTimeSeries_removed() {
Instant now = Instant.now(_htsMaster.getClock());
UniqueId uniqueId = UniqueId.of("DbHts", "102", "0");
_htsMaster.remove(uniqueId);
HistoricalTimeSeriesInfoDocument test = _htsMaster.get(uniqueId);
assertEquals(uniqueId, test.getUniqueId());
assertEquals(_version1Instant, test.getVersionFromInstant());
assertEquals(now, test.getVersionToInstant());
assertEquals(_version1Instant, test.getCorrectionFromInstant());
assertEquals(null, test.getCorrectionToInstant());
assertEquals(uniqueId, test.getInfo().getUniqueId());
}
//-------------------------------------------------------------------------
@Test
public void test_toString() {
assertEquals(_htsMaster.getClass().getSimpleName() + "[DbHts]", _htsMaster.toString());
}
}