// ------------------------------------------------------------------------- @Test public void test_basics() throws Exception { assertNotNull(_secMaster); assertEquals(true, _secMaster.getUniqueIdScheme().equals("DbSec")); assertNotNull(_secMaster.getDbConnector()); assertNotNull(_secMaster.getClock()); }
// ------------------------------------------------------------------------- @Test(enabled = false) public void test_equity() throws Exception { EquitySecurity sec = new EquitySecurity("London", "LON", "OpenGamma Ltd", Currency.GBP); sec.setName("OpenGamma"); sec.setGicsCode(GICSCode.of("20102010")); sec.setShortName("OG"); sec.setExternalIdBundle(ExternalIdBundle.of("Test", "OG")); SecurityDocument addDoc = new SecurityDocument(sec); SecurityDocument added = _secMaster.add(addDoc); SecurityDocument loaded = _secMaster.get(added.getUniqueId()); assertEquals(added, loaded); }
// ------------------------------------------------------------------------- @Test(enabled = false) public void test_bond() throws Exception { ZonedDateTime zdt = ZonedDateTime.parse("2011-01-31T12:00Z[Europe/London]"); GovernmentBondSecurity sec = new GovernmentBondSecurity( "US TREASURY N/B", "issuerType", "issuerDomicile", "market", Currency.GBP, SimpleYieldConvention.US_TREASURY_EQUIVALANT, new Expiry(zdt), "couponType", 23.5d, SimpleFrequency.ANNUAL, DayCountFactory.INSTANCE.getDayCount("Act/Act"), zdt, zdt, zdt, 129d, 1324d, 12d, 1d, 2d, 3d); sec.addExternalId(ExternalId.of("abc", "def")); SecurityDocument addDoc = new SecurityDocument(sec); SecurityDocument added = _secMaster.add(addDoc); SecurityDocument loaded = _secMaster.get(added.getUniqueId()); assertEquals(added, loaded); BondSecuritySearchRequest request = new BondSecuritySearchRequest(); request.setIssuerName("*TREASURY*"); SecuritySearchResult result = _secMaster.search(request); assertEquals(1, result.getDocuments().size()); assertEquals(loaded, result.getFirstDocument()); }
private void init() throws Exception { super.setUp(); ConfigurableApplicationContext context = DbMasterTestUtils.getContext(getDatabaseType()); _secMaster = (DbSecurityMaster) context.getBean(getDatabaseType() + "DbSecurityMaster"); // id bigint not null, // oid bigint not null, // ver_from_instant timestamp not null, // ver_to_instant timestamp not null, // corr_from_instant timestamp not null, // corr_to_instant timestamp not null, // name varchar(255) not null, // sec_type varchar(255) not null, Instant now = Instant.now(); _secMaster.setTimeSource(TimeSource.fixed(now)); _version1Instant = now.minusSeconds(100); _version2Instant = now.minusSeconds(50); s_logger.debug("test data now: {}", _version1Instant); s_logger.debug("test data later: {}", _version2Instant); final SimpleJdbcTemplate template = _secMaster.getDbConnector().getJdbcTemplate(); template.update( "INSERT INTO sec_security VALUES (?,?,?,?,?, ?,?,?,?)", 101, 101, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestSecurity101", "EQUITY", "D"); template.update( "INSERT INTO sec_security VALUES (?,?,?,?,?, ?,?,?,?)", 102, 102, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestSecurity102", "EQUITY", "D"); template.update( "INSERT INTO sec_security VALUES (?,?,?,?,?, ?,?,?,?)", 201, 201, toSqlTimestamp(_version1Instant), toSqlTimestamp(_version2Instant), toSqlTimestamp(_version1Instant), MAX_SQL_TIMESTAMP, "TestSecurity201", "EQUITY", "D"); template.update( "INSERT INTO sec_security VALUES (?,?,?,?,?, ?,?,?,?)", 202, 201, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, toSqlTimestamp(_version2Instant), MAX_SQL_TIMESTAMP, "TestSecurity202", "EQUITY", "D"); _totalSecurities = 3; // id bigint not null, // key_scheme varchar(255) not null, // key_value varchar(255) not null, template.update("INSERT INTO sec_idkey VALUES (?,?,?)", 1, "A", "B"); template.update("INSERT INTO sec_idkey VALUES (?,?,?)", 2, "C", "D"); template.update("INSERT INTO sec_idkey VALUES (?,?,?)", 3, "E", "F"); template.update("INSERT INTO sec_idkey VALUES (?,?,?)", 4, "G", "HI"); // security_id bigint not null, // idkey_id bigint not null, template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 101, 1); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 101, 2); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 101, 3); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 102, 1); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 102, 2); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 102, 4); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 201, 2); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 201, 3); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 202, 2); template.update("INSERT INTO sec_security2idkey VALUES (?,?)", 202, 3); }
// ------------------------------------------------------------------------- @Override protected void doSetUp() { _secMaster = new DbSecurityMaster(getDbConnector()); _secMaster.setDetailProvider(new HibernateSecurityMasterDetailProvider()); }
// ------------------------------------------------------------------------- @Test public void test_toString() { assertEquals("DbSecurityMaster[DbSec]", _secMaster.toString()); }