@Test
public void testGetServiceStatementsAfterSettingInactiveThenActive() throws Exception {
ServiceElement element = makeServiceElement("Buckwheat");
Assert.assertNotNull(element);
ServiceStatement statement = serviceStatementManager.get(element);
Assert.assertNotNull(statement);
ServiceRecord[] records = statement.getServiceRecords();
Assert.assertEquals(1, records.length);
ServiceRecord inActiveServiceRecord = records[0];
inActiveServiceRecord.setType(ServiceRecord.INACTIVE_SERVICE_RECORD);
/* Putting the INACTIVE_SERVICE_RECORD ServiceRecord will replace the ACTIVE_SERVICE_RECORD since the
* records have the same Uuid */
statement.putServiceRecord(recordingUuid, inActiveServiceRecord);
ServiceRecord activeServiceRecord = new ServiceRecord(UuidFactory.generate(),
statement.getServiceElement(),
"hostname");
statement.putServiceRecord(recordingUuid, activeServiceRecord);
Assert.assertEquals(2, statement.getServiceRecords().length);
serviceStatementManager.record(statement);
ServiceStatement fetchedStatement = serviceStatementManager.get(element);
Assert.assertNotNull(fetchedStatement);
Assert.assertEquals(2, fetchedStatement.getServiceRecords().length);
ServiceRecord[] activeRecords = fetchedStatement.getServiceRecords(ServiceRecord.ACTIVE_SERVICE_RECORD);
Assert.assertEquals(1, activeRecords.length);
}