Search in sources :

Example 6 with UnauthorizedFault

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

the class SMLFuncTest method testMigrate.

@Test
public void testMigrate() 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));
    final IParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme(TEST_BUSINESS_IDENTIFIER1);
    aPIClientOld.create(SMP_ID, aPI);
    final String sMigrationKey = aPIClientOld.prepareToMigrate(aPI, SMP_ID);
    assertNotNull(sMigrationKey);
    aPIClientNew.migrate(aPI, sMigrationKey, SMP_ID2);
    try {
        aPIClientOld.delete(SMP_ID, aPI);
        fail();
    } catch (final UnauthorizedFault e) {
    // This must happen.
    }
    // Should be able to delete, since New is now the owner
    aPIClientNew.delete(SMP_ID, aPI);
}
Also used : UnauthorizedFault(com.helger.peppol.smlclient.participant.UnauthorizedFault) ManageServiceMetadataServiceCaller(com.helger.peppol.smlclient.ManageServiceMetadataServiceCaller) NotFoundFault(com.helger.peppol.smlclient.smp.NotFoundFault) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Aggregations

ManageParticipantIdentifierServiceCaller (com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller)6 UnauthorizedFault (com.helger.peppol.smlclient.participant.UnauthorizedFault)6 Test (org.junit.Test)4 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)3 PeppolParticipantIdentifier (com.helger.peppolid.peppol.participant.PeppolParticipantIdentifier)3 CMimeType (com.helger.commons.mime.CMimeType)2 MimeType (com.helger.commons.mime.MimeType)2 BasicAuthClientCredentials (com.helger.http.basicauth.BasicAuthClientCredentials)2 ISMLInfo (com.helger.peppol.sml.ISMLInfo)2 BadRequestFault (com.helger.peppol.smlclient.participant.BadRequestFault)2 InternalErrorFault (com.helger.peppol.smlclient.participant.InternalErrorFault)2 NotFoundFault (com.helger.peppol.smlclient.participant.NotFoundFault)2 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)2 ISMPParticipantMigration (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration)2 ISMPParticipantMigrationManager (com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager)2 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)2 SMPBadRequestException (com.helger.phoss.smp.exception.SMPBadRequestException)2 SMPPreconditionFailedException (com.helger.phoss.smp.exception.SMPPreconditionFailedException)2 SMPSMLException (com.helger.phoss.smp.exception.SMPSMLException)2 ISMPServerAPIDataProvider (com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider)2