use of com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup in project phoss-smp by phax.
the class SMPServiceInformationTest method testBasic.
@Test
public void testBasic() {
final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("0088:dummy");
final ISMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
final XMLOffsetDateTime aStartDT = PDTFactory.getCurrentXMLOffsetDateTime();
final XMLOffsetDateTime aEndDT = aStartDT.plusYears(1);
final SMPEndpoint aEP = new SMPEndpoint("tp", "http://localhost/as2", false, "minauth", aStartDT, aEndDT, "cert", "sd", "tc", "ti", "<extep/>");
assertEquals("tp", aEP.getTransportProfile());
assertEquals("http://localhost/as2", aEP.getEndpointReference());
assertFalse(aEP.isRequireBusinessLevelSignature());
assertEquals("minauth", aEP.getMinimumAuthenticationLevel());
assertEquals(aStartDT, aEP.getServiceActivationDateTime());
assertEquals(aEndDT, aEP.getServiceExpirationDateTime());
assertEquals("cert", aEP.getCertificate());
assertEquals("sd", aEP.getServiceDescription());
assertEquals("tc", aEP.getTechnicalContactUrl());
assertEquals("ti", aEP.getTechnicalInformationUrl());
assertEquals("[{\"Any\":\"<extep />\"}]", aEP.getExtensionsAsString());
final IProcessIdentifier aProcessID = new SimpleProcessIdentifier(PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME, "testproc");
final SMPProcess aProcess = new SMPProcess(aProcessID, CollectionHelper.newList(aEP), "<extproc/>");
assertEquals(aProcessID, aProcess.getProcessIdentifier());
assertEquals(1, aProcess.getAllEndpoints().size());
assertEquals("[{\"Any\":\"<extproc />\"}]", aProcess.getExtensionsAsString());
final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testdoctype");
final SMPServiceInformation aSI = new SMPServiceInformation(aSG, aDocTypeID, CollectionHelper.newList(aProcess), "<extsi/>");
assertSame(aSG, aSI.getServiceGroup());
assertEquals(aDocTypeID, aSI.getDocumentTypeIdentifier());
assertEquals(1, aSI.getAllProcesses().size());
assertEquals("[{\"Any\":\"<extsi />\"}]", aSI.getExtensionsAsString());
}
use of com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup in project phoss-smp by phax.
the class SMPRedirectTest method testBasic.
@Test
public void testBasic() {
final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testdoctype");
final SMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
// Create new one
final ISMPRedirect aRedirect = new SMPRedirect(aSG, aDocTypeID, "target", "suid", null, "<extredirect/>");
assertSame(aSG, aRedirect.getServiceGroup());
assertEquals(aDocTypeID, aRedirect.getDocumentTypeIdentifier());
assertEquals("target", aRedirect.getTargetHref());
assertEquals("suid", aRedirect.getSubjectUniqueIdentifier());
assertNull(aRedirect.getCertificate());
assertFalse(aRedirect.hasCertificate());
assertEquals("[{\"Any\":\"<extredirect />\"}]", aRedirect.getExtensionsAsString());
}
use of com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup in project phoss-smp by phax.
the class SMPServiceInformationTest method testMinimal.
@Test
public void testMinimal() {
final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
final ISMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
final SMPEndpoint aEP = new SMPEndpoint("tp", "http://localhost/as2", false, (String) null, (XMLOffsetDateTime) null, (XMLOffsetDateTime) null, "cert", "sd", "tc", (String) null, (String) null);
assertEquals("tp", aEP.getTransportProfile());
assertEquals("http://localhost/as2", aEP.getEndpointReference());
assertFalse(aEP.isRequireBusinessLevelSignature());
assertNull(aEP.getMinimumAuthenticationLevel());
assertNull(aEP.getServiceActivationDateTime());
assertNull(aEP.getServiceExpirationDateTime());
assertEquals("cert", aEP.getCertificate());
assertEquals("sd", aEP.getServiceDescription());
assertEquals("tc", aEP.getTechnicalContactUrl());
assertNull(aEP.getTechnicalInformationUrl());
assertNull(aEP.getExtensionsAsString());
final IProcessIdentifier aProcessID = new SimpleProcessIdentifier(PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME, "testproc");
final SMPProcess aProcess = new SMPProcess(aProcessID, CollectionHelper.newList(aEP), (String) null);
assertEquals(aProcessID, aProcess.getProcessIdentifier());
assertEquals(1, aProcess.getAllEndpoints().size());
assertNull(aProcess.getExtensionsAsString());
final IDocumentTypeIdentifier aDocTypeID = new SimpleDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "testdoctype");
final SMPServiceInformation aSI = new SMPServiceInformation(aSG, aDocTypeID, CollectionHelper.newList(aProcess), (String) null);
assertSame(aSG, aSI.getServiceGroup());
assertEquals(aDocTypeID, aSI.getDocumentTypeIdentifier());
assertEquals(1, aSI.getAllProcesses().size());
assertNull(aSI.getExtensionsAsString());
}
use of com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup in project phoss-smp by phax.
the class SMPBusinessCardTest method testBasic.
@Test
public void testBasic() {
final IParticipantIdentifier aPI = new SimpleParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
final SMPServiceGroup aSG = new SMPServiceGroup(CSecurity.USER_ADMINISTRATOR_ID, aPI, null);
// Test empty
{
final SMPBusinessCard aBC = new SMPBusinessCard(aPI, new CommonsArrayList<>());
assertEquals(aPI, aBC.getParticipantIdentifier());
assertEquals(aSG.getID(), aBC.getID());
assertNotNull(aBC.getAllEntities());
assertTrue(aBC.getAllEntities().isEmpty());
_testXMLConversion(aBC);
}
// with entities
{
final SMPBusinessCardEntity aEntity1 = new SMPBusinessCardEntity();
aEntity1.names().add(new SMPBusinessCardName("Name 1", "de"));
aEntity1.names().add(new SMPBusinessCardName("Name 2", null));
aEntity1.setCountryCode("AT");
aEntity1.setGeographicalInformation("here\nthere\r\neverywhere");
aEntity1.identifiers().add(new SMPBusinessCardIdentifier("scheme1", "value1"));
aEntity1.identifiers().add(new SMPBusinessCardIdentifier("scheme 2", "value 2"));
aEntity1.websiteURIs().add("http://www.helger.com");
aEntity1.websiteURIs().add("https://github.com/phax/phoss-smp");
aEntity1.contacts().add(new SMPBusinessCardContact("type 1", "Whoever", "with a phone", "and@an.email.org"));
aEntity1.contacts().add(new SMPBusinessCardContact("type 2", "Whoever else", "without a phone", "but@an.email.org"));
aEntity1.setAdditionalInformation("this is line1\nfollowed by line 2\r\nand now eoai");
aEntity1.setRegistrationDate(PDTFactory.getCurrentLocalDate());
final SMPBusinessCardEntity aEntity2 = new SMPBusinessCardEntity();
aEntity2.names().add(new SMPBusinessCardName("Name 1", "de"));
aEntity2.names().add(new SMPBusinessCardName("Name 2", null));
aEntity2.setCountryCode("UK");
aEntity2.setGeographicalInformation("here\nthere\r\neverywhere");
aEntity2.identifiers().add(new SMPBusinessCardIdentifier("scheme1", "value1"));
aEntity2.identifiers().add(new SMPBusinessCardIdentifier("scheme 2", "value 2"));
aEntity2.websiteURIs().add("http://www.helger.com");
aEntity2.websiteURIs().add("https://github.com/phax/phoss-smp");
aEntity2.contacts().add(new SMPBusinessCardContact("type 1", "Whoever", "with a phone", "and@an.email.org"));
aEntity2.contacts().add(new SMPBusinessCardContact("type 2", "Whoever else", "without a phone", "but@an.email.org"));
aEntity2.setAdditionalInformation("this is line1\nfollowed by line 2\r\nand now eoai");
aEntity2.setRegistrationDate(PDTFactory.getCurrentLocalDate());
final SMPBusinessCardEntity aEntity3 = new SMPBusinessCardEntity();
aEntity3.names().add(new SMPBusinessCardName("Shorty", null));
aEntity3.setCountryCode("US");
final SMPBusinessCard aBC = new SMPBusinessCard(aPI, new CommonsArrayList<>(aEntity1, aEntity2, aEntity3));
assertEquals(aPI, aBC.getParticipantIdentifier());
assertEquals(aSG.getID(), aBC.getID());
assertNotNull(aBC.getAllEntities());
assertEquals(3, aBC.getAllEntities().size());
_testXMLConversion(aBC);
}
}
use of com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup in project phoss-smp by phax.
the class SMPServiceGroupManagerJDBC method getSMPServiceGroupOfID.
@Nullable
public SMPServiceGroup getSMPServiceGroupOfID(@Nullable final IParticipantIdentifier aParticipantID) {
if (LOGGER.isDebugEnabled())
LOGGER.debug("getSMPServiceGroupOfID(" + (aParticipantID == null ? "null" : aParticipantID.getURIEncoded()) + ")");
if (aParticipantID == null)
return null;
// Use cache
SMPServiceGroup ret = m_aCache == null ? null : m_aCache.get(aParticipantID.getURIEncoded());
if (ret != null)
return ret;
// Not in cache
final Wrapper<DBResultRow> aResult = new Wrapper<>();
newExecutor().querySingle("SELECT sg.extension, so.username" + " FROM smp_service_group sg, smp_ownership so" + " WHERE sg.businessIdentifierScheme=? AND sg.businessIdentifier=?" + " AND so.businessIdentifierScheme=sg.businessIdentifierScheme AND so.businessIdentifier=sg.businessIdentifier", new ConstantPreparedStatementDataProvider(aParticipantID.getScheme(), aParticipantID.getValue()), aResult::set);
if (aResult.isNotSet())
return null;
ret = new SMPServiceGroup(aResult.get().getAsString(1), aParticipantID, aResult.get().getAsString(0));
if (m_aCache != null)
m_aCache.put(aParticipantID.getURIEncoded(), ret);
return ret;
}
Aggregations