NdsBeisEsb/src/test/java/com/northgateps/nds/beis/esb/beisregistration/BeisRegistrationRouteTest.java
/**
     * When a user is created the party reference received from MaintainPartydDetails
     * Foundation Layer call is stored as the uid against the FOUNDATION_LAYER_PARTY_SERVICE
     * against the user. This test makes sure this happens with a mocked out MaintainPartyDetails
     * call. 
     */
When a user is created the party reference received from MaintainPartydDetails
Foundation Layer call is stored as the uid against the FOUNDATION_LAYER_PARTY_SERVICE
against the user. This test makes sure this happens with a mocked out MaintainPartyDetails
call.
When a user is created the party reference received from MaintainPartydDetails Foundation Layer call is stored as the uid against the FOUNDATION_LAYER_PARTY_SERVICE against the user . This test makes sure this happens with a mocked out MaintainPartyDetails call .
@Test
    public void testFoundationLayerReferenceIsSaved() throws Exception {
        assumeTrue(connection);
        MockNdsDirectoryKernel mockDirectoryKernel = new MockNdsDirectoryKernel();
        Boolean foundationLayerReferenceIsSaved = false;
        final BeisRegistrationDetails newUserDetails = registerNewUser(null,mockDirectoryKernel);
        logger.info("Created new user, testing party ref is persisted from foundation layer");
        String serviceName = configurationManager.getString("service.foundationLayerPartyService.name");
        String userDn = NdsDirectoryComponent.getUserDn(configurationManager,
                newUserDetails.getUserDetails().getUsername(), TENANT);
        DirectoryConnectionConfig directoryConnectionConfig = new DirectoryConnectionConfig(configurationManager);
        try (DirectoryAccessConnection directoryConnection = mockDirectoryKernel.getDirectoryConnection(directoryConnectionConfig)) {
            DirectoryManager directoryManager = new DirectoryManager();
            directoryManager.setKernel(mockDirectoryKernel);
            UserManager userManager = new UserManager();
            userManager.setDirectoryManager(directoryManager);
            ServiceAccessDetails serviceAccessDetails = userManager.serviceLookup(directoryConnection, userDn,
                    serviceName, true, true, false);
            if (serviceAccessDetails.getUserId() != null &&
                    !serviceAccessDetails.getUserId().isEmpty() &&   
                    !serviceAccessDetails.getUserId().contains("-")){
                    foundationLayerReferenceIsSaved = true;
            }               
        }
        assertTrue("The party reference from MaintainPartyDetails has not been saved in LDAP (FOUNDATION_LAYER_PARTY_SERVICE.uid)", 
                   foundationLayerReferenceIsSaved); 
    }
@ Test public void testFoundationLayerReferenceIsSaved ( ) throws Exception { assumeTrue ( connection ) ; MockNdsDirectoryKernel mockDirectoryKernel = new MockNdsDirectoryKernel ( ) ; Boolean foundationLayerReferenceIsSaved = false ; final BeisRegistrationDetails newUserDetails = registerNewUser ( null , mockDirectoryKernel ) ; logger . info ( "Created new user, testing party ref is persisted from foundation layer" ) ; String serviceName = configurationManager . getString ( "service.foundationLayerPartyService.name" ) ; String userDn = NdsDirectoryComponent . getUserDn ( configurationManager , newUserDetails . getUserDetails ( ) . getUsername ( ) , TENANT ) ; DirectoryConnectionConfig directoryConnectionConfig = new DirectoryConnectionConfig ( configurationManager ) ; try ( DirectoryAccessConnection directoryConnection = mockDirectoryKernel . getDirectoryConnection ( directoryConnectionConfig ) ) { DirectoryManager directoryManager = new DirectoryManager ( ) ; directoryManager . setKernel ( mockDirectoryKernel ) ; UserManager userManager = new UserManager ( ) ; userManager . setDirectoryManager ( directoryManager ) ; ServiceAccessDetails serviceAccessDetails = userManager . serviceLookup ( directoryConnection , userDn , serviceName , true , true , false ) ; if ( serviceAccessDetails . getUserId ( ) != null && ! serviceAccessDetails . getUserId ( ) . isEmpty ( ) && ! serviceAccessDetails . getUserId ( ) . contains ( "-" ) ) { foundationLayerReferenceIsSaved = true ; } } assertTrue ( "The party reference from MaintainPartyDetails has not been saved in LDAP (FOUNDATION_LAYER_PARTY_SERVICE.uid)" , foundationLayerReferenceIsSaved ) ; }
When a user is created the party reference received from MaintainPartydDetails
 Foundation Layer call is stored as the uid against the FOUNDATION_LAYER_PARTY_SERVICE
 against the user.
When a user is created the party reference received from MaintainPartydDetails Foundation Layer call is stored as the uid against the FOUNDATION_LAYER_PARTY_SERVICE against the user .
//Get the service name //Create a connection and retrieve the service details for the user // lookup service details //If the user id looks ok then we have succeeded