use of com.helger.peppol.sml.ESML in project phoss-smp by phax.
the class SMLInfoManagerMongoDBTest method testBasic.
@Test
public void testBasic() {
try (final SMLInfoManagerMongoDB aMgr = new SMLInfoManagerMongoDB()) {
assertEquals(0, aMgr.getAllSMLInfos().size());
final ICommonsList<ISMLInfo> aCreated = aMgr.getAllSMLInfos();
for (final ESML e : ESML.values()) {
final ISMLInfo aCreate = aMgr.createSMLInfo(e.getDisplayName(), e.getDNSZone(), e.getManagementServiceURL(), e.isClientCertificateRequired());
aCreated.add(aCreate);
}
final ICommonsList<ISMLInfo> aAll = aMgr.getAllSMLInfos();
assertEquals(ESML.values().length, aAll.size());
for (final ISMLInfo aCreate : aCreated) assertTrue(aAll.contains(aCreate));
for (final ISMLInfo aCreate : aCreated) assertTrue(aMgr.updateSMLInfo(aCreate.getID(), "bla " + aCreate.getDisplayName(), aCreate.getDNSZone(), aCreate.getManagementServiceURL(), aCreate.isClientCertificateRequired()).isChanged());
for (final ISMLInfo aCreate : aCreated) {
final ISMLInfo aInfo = aMgr.getSMLInfoOfID(aCreate.getID());
assertNotNull(aInfo);
assertTrue(aInfo.getDisplayName().startsWith("bla "));
}
for (final ISMLInfo aCreate : aCreated) assertTrue(aMgr.deleteSMLInfo(aCreate.getID()).isChanged());
assertEquals(0, aMgr.getAllSMLInfos().size());
}
}