Search in sources :

Example 1 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class SMLFuncTest method testManageBusinessIdentifierListWithTwoElement.

@Test
public void testManageBusinessIdentifierListWithTwoElement() throws Exception {
    final ManageParticipantIdentifierServiceCaller aPIClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aPIClient.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    final ICommonsMap<String, IParticipantIdentifier> aBusinessIdentifiersCreate = new CommonsHashMap<>();
    IParticipantIdentifier aBusinessIdentifierCreate1 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER1);
    IParticipantIdentifier aBusinessIdentifierCreate2 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER2);
    aBusinessIdentifiersCreate.put(aBusinessIdentifierCreate1.getValue(), aBusinessIdentifierCreate1);
    aBusinessIdentifiersCreate.put(aBusinessIdentifierCreate2.getValue(), aBusinessIdentifierCreate2);
    aPIClient.createList(aBusinessIdentifiersCreate.values(), SMP_ID);
    final ParticipantIdentifierPageType aResult = aPIClient.list("", m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
    assertNotNull(aResult);
    final List<ParticipantIdentifierType> aBusinessIdentifiers = aResult.getParticipantIdentifier();
    assertEquals(2, aBusinessIdentifiers.size());
    final ParticipantIdentifierType aBusinessIdentifierRead1 = aBusinessIdentifiers.get(0);
    aBusinessIdentifierCreate1 = aBusinessIdentifiersCreate.get(aBusinessIdentifierRead1.getValue());
    final ParticipantIdentifierType aBusinessIdentifierRead2 = aBusinessIdentifiers.get(1);
    aBusinessIdentifierCreate2 = aBusinessIdentifiersCreate.get(aBusinessIdentifierRead2.getValue());
    assertEquals(aBusinessIdentifierCreate1.getScheme(), aBusinessIdentifierRead1.getScheme());
    assertEquals(aBusinessIdentifierCreate1.getValue(), aBusinessIdentifierRead1.getValue());
    assertEquals(aBusinessIdentifierCreate2.getScheme(), aBusinessIdentifierRead2.getScheme());
    assertEquals(aBusinessIdentifierCreate2.getValue(), aBusinessIdentifierRead2.getValue());
    aPIClient.deleteList(aBusinessIdentifiers);
    m_aSMClient.delete(m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
}
Also used : ParticipantIdentifierPageType(com.helger.peppol.smlclient.participant.ParticipantIdentifierPageType) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) ParticipantIdentifierType(com.helger.xsds.peppol.id1.ParticipantIdentifierType) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 2 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class SMLFuncTest method testCreateExistingBusinessIdentifierUnauthorized.

@Test(expected = BadRequestFault.class)
public void testCreateExistingBusinessIdentifierUnauthorized() throws Exception {
    final ManageParticipantIdentifierServiceCaller aPIClientOld = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aPIClientOld.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    final ManageServiceMetadataServiceCaller aClient2 = new ManageServiceMetadataServiceCaller(SML_INFO);
    aClient2.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    try {
        aClient2.delete(SMP_ID2);
    } catch (final NotFoundFault e) {
    // This is fine, since we are just cleaning
    }
    _createSMPData(aClient2, SMP_ID2);
    final ManageParticipantIdentifierServiceCaller aPIClientNew = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aPIClientNew.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    aPIClientOld.create(SMP_ID, PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER1));
    aPIClientNew.create(SMP_ID, PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER1));
}
Also used : ManageServiceMetadataServiceCaller(com.helger.peppol.smlclient.ManageServiceMetadataServiceCaller) NotFoundFault(com.helger.peppol.smlclient.smp.NotFoundFault) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) Test(org.junit.Test)

Example 3 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class SMLFuncTest method testManageBusinessIdentifierDoubleDelete.

@Test(expected = NotFoundFault.class)
public void testManageBusinessIdentifierDoubleDelete() throws Exception {
    final ManageParticipantIdentifierServiceCaller aPIClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aPIClient.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    final IParticipantIdentifier aBusinessIdentifierCreate = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER1);
    final ServiceMetadataPublisherServiceForParticipantType aServiceMetadataPublisherServiceForBusiness = new ServiceMetadataPublisherServiceForParticipantType();
    // Explicit constructor call needed for type conversion
    aServiceMetadataPublisherServiceForBusiness.setParticipantIdentifier(new SimpleParticipantIdentifier(aBusinessIdentifierCreate));
    aServiceMetadataPublisherServiceForBusiness.setServiceMetadataPublisherID(m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
    aPIClient.create(aServiceMetadataPublisherServiceForBusiness);
    final ParticipantIdentifierPageType aResult = aPIClient.list("", m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
    assertNotNull(aResult);
    final List<ParticipantIdentifierType> aBusinessIdentifiers = aResult.getParticipantIdentifier();
    assertEquals(1, aBusinessIdentifiers.size());
    final ParticipantIdentifierType aBusinessIdentifierRead = aBusinessIdentifiers.get(0);
    assertEquals(aBusinessIdentifierCreate.getScheme(), aBusinessIdentifierRead.getScheme());
    assertEquals(aBusinessIdentifierCreate.getValue(), aBusinessIdentifierRead.getValue());
    aPIClient.deleteList(aBusinessIdentifiers);
    aPIClient.deleteList(aBusinessIdentifiers);
    m_aSMClient.delete(m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
}
Also used : ParticipantIdentifierPageType(com.helger.peppol.smlclient.participant.ParticipantIdentifierPageType) ServiceMetadataPublisherServiceForParticipantType(com.helger.peppol.smlclient.participant.ServiceMetadataPublisherServiceForParticipantType) ParticipantIdentifierType(com.helger.xsds.peppol.id1.ParticipantIdentifierType) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 4 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class SMLFuncTest method testManageBusinessIdentifierListWithOneElement.

@Test
public void testManageBusinessIdentifierListWithOneElement() throws Exception {
    final ManageParticipantIdentifierServiceCaller aPIClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
    aPIClient.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
    final ICommonsList<IParticipantIdentifier> aRecipientBusinessIdentifiers = new CommonsArrayList<>();
    final IParticipantIdentifier aBusinessIdentifierCreate1 = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER1);
    aRecipientBusinessIdentifiers.add(aBusinessIdentifierCreate1);
    aPIClient.createList(aRecipientBusinessIdentifiers, SMP_ID);
    final ParticipantIdentifierPageType aResult = aPIClient.list("", m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
    assertNotNull(aResult);
    final List<ParticipantIdentifierType> aBusinessIdentifiers = aResult.getParticipantIdentifier();
    assertEquals(1, aBusinessIdentifiers.size());
    final ParticipantIdentifierType aBusinessIdentifierRead = aBusinessIdentifiers.get(0);
    assertEquals(aBusinessIdentifierCreate1.getScheme(), aBusinessIdentifierRead.getScheme());
    assertEquals(aBusinessIdentifierCreate1.getValue(), aBusinessIdentifierRead.getValue());
    aPIClient.deleteList(aBusinessIdentifiers);
    m_aSMClient.delete(m_aServiceMetadataPublisher.getServiceMetadataPublisherID());
}
Also used : ParticipantIdentifierPageType(com.helger.peppol.smlclient.participant.ParticipantIdentifierPageType) ParticipantIdentifierType(com.helger.xsds.peppol.id1.ParticipantIdentifierType) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 5 with ManageParticipantIdentifierServiceCaller

use of com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller in project peppol-commons by phax.

the class WildcardFuncTest method testCreateWildcardUnauthorizedFault_WrongScheme.

@Test
public void testCreateWildcardUnauthorizedFault_WrongScheme() throws Exception {
    try {
        final ManageParticipantIdentifierServiceCaller aPIClient = new ManageParticipantIdentifierServiceCaller(SML_INFO);
        aPIClient.setSSLSocketFactory(createConfiguredSSLSocketFactory(SML_INFO, false));
        aPIClient.create(SMP_ID, new PeppolParticipantIdentifier(BUSINESS_IDENTIFIER_SCHEME, "*"));
        fail("User should not be allowed to register wild card for this scheme : " + BUSINESS_IDENTIFIER_SCHEME);
    } catch (final UnauthorizedFault e) {
        assertTrue(e.getMessage().contains("The user is not allowed to register Wildcard for this scheme"));
    }
}
Also used : PeppolParticipantIdentifier(com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier) UnauthorizedFault(com.helger.peppol.smlclient.participant.UnauthorizedFault) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) Test(org.junit.Test)

Aggregations

ManageParticipantIdentifierServiceCaller (com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller)23 Test (org.junit.Test)16 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)13 UnauthorizedFault (com.helger.peppol.smlclient.participant.UnauthorizedFault)6 PeppolParticipantIdentifier (com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier)6 ParticipantIdentifierPageType (com.helger.peppol.smlclient.participant.ParticipantIdentifierPageType)5 ParticipantIdentifierType (com.helger.xsds.peppol.id1.ParticipantIdentifierType)5 ISMLInfo (com.helger.peppol.sml.ISMLInfo)4 ManageServiceMetadataServiceCaller (com.helger.peppol.smlclient.ManageServiceMetadataServiceCaller)4 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)4 ISMPParticipantMigrationManager (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager)4 ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)4 BadRequestFault (com.helger.peppol.smlclient.participant.BadRequestFault)3 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)3 IMicroDocument (com.helger.xml.microdom.IMicroDocument)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 PDTToString (com.helger.commons.datetime.PDTToString)2 CMimeType (com.helger.commons.mime.CMimeType)2 MimeType (com.helger.commons.mime.MimeType)2 BasicAuthClientCredentials (com.helger.http.basicauth.BasicAuthClientCredentials)2