Search in sources :

Example 1 with AssetRecordDao

use of org.opennms.netmgt.dao.api.AssetRecordDao in project opennms by OpenNMS.

the class AbstractNodeRestServiceTest method verifyCreationWithAssetRecord.

// See NMS-9855
@Test
public void verifyCreationWithAssetRecord() {
    final String node = "<node type=\"A\" label=\"TestMachine1\" foreignSource=\"SmokeTests\" foreignId=\"TestMachine1\">" + "<assetRecord>" + "<description>Right here, right now</description>" + "</assetRecord>" + "<labelSource>H</labelSource>" + "<sysContact>The Owner</sysContact>" + "<sysDescription>" + "Darwin TestMachine 9.4.0 Darwin Kernel Version 9.4.0: Mon Jun  9 19:30:53 PDT 2008; root:xnu-1228.5.20~1/RELEASE_I386 i386" + "</sysDescription>" + "<sysLocation>DevJam</sysLocation>" + "<sysName>TestMachine1</sysName>" + "<sysObjectId>.1.3.6.1.4.1.8072.3.2.255</sysObjectId>" + "<createTime>2011-09-24T07:12:46.421-04:00</createTime>" + "<lastCapsdPoll>2011-09-24T07:12:46.421-04:00</lastCapsdPoll>" + "</node>";
    given().body(node).contentType(ContentType.XML).post().then().assertThat().statusCode(201);
    // Verify that only one asset record has been created
    final HibernateDaoFactory daoFactory = new HibernateDaoFactory(getPostgresService());
    final AssetRecordDao dao = daoFactory.getDao(AssetRecordDaoHibernate.class);
    assertThat(dao.countAll(), is(1));
    // Ensure we can get nodes with asset records attached
    given().get().then().log().all().and().assertThat().statusCode(200);
}
Also used : HibernateDaoFactory(org.opennms.smoketest.utils.HibernateDaoFactory) AssetRecordDao(org.opennms.netmgt.dao.api.AssetRecordDao) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AssetRecordDao (org.opennms.netmgt.dao.api.AssetRecordDao)1 HibernateDaoFactory (org.opennms.smoketest.utils.HibernateDaoFactory)1