service-registry/src/test/java/de/evoila/osb/service/registry/EndToEndTest.java
@Test
    public void runTest() throws ResourceNotFoundException {
        ServiceBrokerCreate serviceBrokerCreate = ServiceBrokerMockClient.getServiceBrokerCreate();
        ServiceInstanceRequest instanceRequest = ServiceBrokerMockClient.getServiceInstanceRequest(sbMock);
        ServiceInstanceRequest sharedInstanceRequest = ServiceBrokerMockClient.getSharedServiceInstanceRequest(sbMock, ServiceBrokerMockClient.TEST_INSTANCE_1);
        ServiceInstanceBindingRequest bindingRequest = ServiceBrokerMockClient.getBindingRequest(sbMock);
        String serviceDefinitionId = instanceRequest.getServiceDefinitionId();
        String planId = instanceRequest.getPlanId();
        String sharedServiceDefinitionId = SharedInstancesManager.SHARED_DEFINITIONS_ID;

        // Check the availability of used services and managers
        checkAutowiring();

        // Check pre conditions
        checkCatalog(true, false);
        checkEmptyStorage();

        // Register new service broker and check catalog afterwards
        String brokerId = registerBroker(0, serviceBrokerCreate);
        ResponseEntity<CatalogResponse> catalogResponse = checkCatalog(false, false);

        // Fill values of singleton of ServiceBrokerMockClient for later use
        sbMock.setupMock(catalogResponse.getBody().getServices(), ServiceBrokerMockClient.SERVICE_BROKER_ORG, ServiceBrokerMockClient.SERVICE_BROKER_SPACE);

        // Provision original instance and add a binding
        String instanceId = provisionInstance(0,
                instanceRequest,
                ServiceBrokerMockClient.TEST_INSTANCE_1,
                false,
                null);
        String binding1Id = bind(0, bindingRequest, instanceId, ServiceBrokerMockClient.TEST_BINDING_1);

        // Try to unregister broker -> should be blocked
        unregisterBroker(1, brokerId, true);

        // Share original instance and check definition in catalog
        shareInstance(instanceId);
        checkCatalog(false, true);

        // Create a shared instance
        String sharedInstanceId = provisionInstance(1,
                sharedInstanceRequest,
                ServiceBrokerMockClient.TEST_INSTANCE_1_SHARED,
                true,
                instanceId);

        // Create bindings on original and shared instance
        String sharedBinding1Id = bind(1, bindingRequest, sharedInstanceId, ServiceBrokerMockClient.TEST_BINDING_OF_SHARED_1);
        String binding2Id = bind(2, bindingRequest, instanceId, ServiceBrokerMockClient.TEST_BINDING_2);

        // Try to delete instances with active bindings -> should be blocked
        deleteInstance(2, instanceId, serviceDefinitionId, planId, true);
        deleteInstance(2, sharedInstanceId, sharedInstanceRequest.getServiceDefinitionId(), sharedInstanceRequest.getPlanId(), true);

        // Try to unshare instances that have more than one reference -> should be blocked
        unshareInstance(instanceId, false);
        unshareInstance(sharedInstanceId, false);

        // Delete all bindings of original instance
        unbind(3, instanceId, binding1Id, serviceDefinitionId, planId);
        unbind(2, instanceId, binding2Id, serviceDefinitionId, planId);

        // Delete original instance and check catalog
        deleteInstance(2, instanceId, serviceDefinitionId, planId, false);
        checkCatalog(false, true);

        // Try to unregister broker after original instance was unprovisioned -> should be blocked
        unregisterBroker(1, brokerId, true);

        // Create new binding on shared instance with original instance being deleted
        String sharedBinding2Id = bind(1, bindingRequest, sharedInstanceId, ServiceBrokerMockClient.TEST_BINDING_OF_SHARED_2);

        // Unshare instance
        unshareInstance(sharedInstanceId, true);
        checkCatalog(false, false);

        // Delete bindings of shared instance
        unbind(2, sharedInstanceId, sharedBinding1Id, sharedServiceDefinitionId, instanceId);
        unbind(1, sharedInstanceId, sharedBinding2Id, sharedServiceDefinitionId, instanceId);

        // Unprovision shared instance
        deleteInstance(1, sharedInstanceId, sharedInstanceRequest.getServiceDefinitionId(), sharedInstanceRequest.getPlanId(), false);

        // Unregister service broker
        unregisterBroker(1, brokerId, false);

        // Check post conditions
        checkCatalog(true, false);
        checkEmptyStorage();

    }
/**
     * This test fulfills a end-to-end test for sharing instances.
     * In it following steps are done and checked in order:
     * <ul>
     * <li>Used managers and services autowiring</li>
     * <li>Pre Test condition</li>
     * <li>Service Broker registration</li>
     * <li>Service instance provisioning</li>
     * <li>Service binding creation</li>
     * <li>Sharing a service instance</li>
     * <li>Catalog after sharing a service instance</li>
     * <li>Shared service instance provisioning</li>
     * <li>Service binding on shared instance creation</li>
     * <li>Catalog after shared service instance provisioning</li>
     * <li>Blocked service instance unprovisioning</li>
     * <li>Blocked unsharing of service instance</li>
     * <li>Binding deletion of original instance</li>
     * <li>Original service instance unprovisioning</li>
     * <li>Catalog after deprovisioning of original instance</li>
     * <li>Service Binding creation on shared service instance after </li>
     * <li>Unsharing the shared instance</li>
     * <li>Binding deletion of shared instance</li>
     * <li>Shared service instance unprovisioning</li>
     * <li>Post Test condition</li>
     *
     * </ul>
     */
This test fulfills a end-to-end test for sharing instances.
In it following steps are done and checked in order:

Used managers and services autowiring
Pre Test condition
Service Broker registration
Service instance provisioning
Service binding creation
Sharing a service instance
Catalog after sharing a service instance
Shared service instance provisioning
Service binding on shared instance creation
Catalog after shared service instance provisioning
Blocked service instance unprovisioning
Blocked unsharing of service instance
Binding deletion of original instance
Original service instance unprovisioning
Catalog after deprovisioning of original instance
Service Binding creation on shared service instance after 
Unsharing the shared instance
Binding deletion of shared instance
Shared service instance unprovisioning
Post Test condition


This test fulfills a end - to - end test for sharing instances . In it following steps are done and checked in order : Used managers and services autowiring Pre Test condition Service Broker registration Service instance provisioning Service binding creation Sharing a service instance Catalog after sharing a service instance Shared service instance provisioning Service binding on shared instance creation Catalog after shared service instance provisioning Blocked service instance unprovisioning Blocked unsharing of service instance Binding deletion of original instance Original service instance unprovisioning Catalog after deprovisioning of original instance Service Binding creation on shared service instance after Unsharing the shared instance Binding deletion of shared instance Shared service instance unprovisioning Post Test condition
@Test
    public void runTest() throws ResourceNotFoundException {
        ServiceBrokerCreate serviceBrokerCreate = ServiceBrokerMockClient.getServiceBrokerCreate();
        ServiceInstanceRequest instanceRequest = ServiceBrokerMockClient.getServiceInstanceRequest(sbMock);
        ServiceInstanceRequest sharedInstanceRequest = ServiceBrokerMockClient.getSharedServiceInstanceRequest(sbMock, ServiceBrokerMockClient.TEST_INSTANCE_1);
        ServiceInstanceBindingRequest bindingRequest = ServiceBrokerMockClient.getBindingRequest(sbMock);
        String serviceDefinitionId = instanceRequest.getServiceDefinitionId();
        String planId = instanceRequest.getPlanId();
        String sharedServiceDefinitionId = SharedInstancesManager.SHARED_DEFINITIONS_ID;
        checkAutowiring();
        checkCatalog(true, false);
        checkEmptyStorage();
        String brokerId = registerBroker(0, serviceBrokerCreate);
        ResponseEntity<CatalogResponse> catalogResponse = checkCatalog(false, false);
        sbMock.setupMock(catalogResponse.getBody().getServices(), ServiceBrokerMockClient.SERVICE_BROKER_ORG, ServiceBrokerMockClient.SERVICE_BROKER_SPACE);
        String instanceId = provisionInstance(0,
                instanceRequest,
                ServiceBrokerMockClient.TEST_INSTANCE_1,
                false,
                null);
        String binding1Id = bind(0, bindingRequest, instanceId, ServiceBrokerMockClient.TEST_BINDING_1);
        unregisterBroker(1, brokerId, true);
        shareInstance(instanceId);
        checkCatalog(false, true);
        String sharedInstanceId = provisionInstance(1,
                sharedInstanceRequest,
                ServiceBrokerMockClient.TEST_INSTANCE_1_SHARED,
                true,
                instanceId);
        String sharedBinding1Id = bind(1, bindingRequest, sharedInstanceId, ServiceBrokerMockClient.TEST_BINDING_OF_SHARED_1);
        String binding2Id = bind(2, bindingRequest, instanceId, ServiceBrokerMockClient.TEST_BINDING_2);
        deleteInstance(2, instanceId, serviceDefinitionId, planId, true);
        deleteInstance(2, sharedInstanceId, sharedInstanceRequest.getServiceDefinitionId(), sharedInstanceRequest.getPlanId(), true);
        unshareInstance(instanceId, false);
        unshareInstance(sharedInstanceId, false);
        unbind(3, instanceId, binding1Id, serviceDefinitionId, planId);
        unbind(2, instanceId, binding2Id, serviceDefinitionId, planId);
        deleteInstance(2, instanceId, serviceDefinitionId, planId, false);
        checkCatalog(false, true);
        unregisterBroker(1, brokerId, true);
        String sharedBinding2Id = bind(1, bindingRequest, sharedInstanceId, ServiceBrokerMockClient.TEST_BINDING_OF_SHARED_2);
        unshareInstance(sharedInstanceId, true);
        checkCatalog(false, false);
        unbind(2, sharedInstanceId, sharedBinding1Id, sharedServiceDefinitionId, instanceId);
        unbind(1, sharedInstanceId, sharedBinding2Id, sharedServiceDefinitionId, instanceId);
        deleteInstance(1, sharedInstanceId, sharedInstanceRequest.getServiceDefinitionId(), sharedInstanceRequest.getPlanId(), false);
        unregisterBroker(1, brokerId, false);
        checkCatalog(true, false);
        checkEmptyStorage();
    }
@ Test public void runTest ( ) throws ResourceNotFoundException { ServiceBrokerCreate serviceBrokerCreate = ServiceBrokerMockClient . getServiceBrokerCreate ( ) ; ServiceInstanceRequest instanceRequest = ServiceBrokerMockClient . getServiceInstanceRequest ( sbMock ) ; ServiceInstanceRequest sharedInstanceRequest = ServiceBrokerMockClient . getSharedServiceInstanceRequest ( sbMock , ServiceBrokerMockClient . TEST_INSTANCE_1 ) ; ServiceInstanceBindingRequest bindingRequest = ServiceBrokerMockClient . getBindingRequest ( sbMock ) ; String serviceDefinitionId = instanceRequest . getServiceDefinitionId ( ) ; String planId = instanceRequest . getPlanId ( ) ; String sharedServiceDefinitionId = SharedInstancesManager . SHARED_DEFINITIONS_ID ; checkAutowiring ( ) ; checkCatalog ( true , false ) ; checkEmptyStorage ( ) ; String brokerId = registerBroker ( 0 , serviceBrokerCreate ) ; ResponseEntity < CatalogResponse > catalogResponse = checkCatalog ( false , false ) ; sbMock . setupMock ( catalogResponse . getBody ( ) . getServices ( ) , ServiceBrokerMockClient . SERVICE_BROKER_ORG , ServiceBrokerMockClient . SERVICE_BROKER_SPACE ) ; String instanceId = provisionInstance ( 0 , instanceRequest , ServiceBrokerMockClient . TEST_INSTANCE_1 , false , null ) ; String binding1Id = bind ( 0 , bindingRequest , instanceId , ServiceBrokerMockClient . TEST_BINDING_1 ) ; unregisterBroker ( 1 , brokerId , true ) ; shareInstance ( instanceId ) ; checkCatalog ( false , true ) ; String sharedInstanceId = provisionInstance ( 1 , sharedInstanceRequest , ServiceBrokerMockClient . TEST_INSTANCE_1_SHARED , true , instanceId ) ; String sharedBinding1Id = bind ( 1 , bindingRequest , sharedInstanceId , ServiceBrokerMockClient . TEST_BINDING_OF_SHARED_1 ) ; String binding2Id = bind ( 2 , bindingRequest , instanceId , ServiceBrokerMockClient . TEST_BINDING_2 ) ; deleteInstance ( 2 , instanceId , serviceDefinitionId , planId , true ) ; deleteInstance ( 2 , sharedInstanceId , sharedInstanceRequest . getServiceDefinitionId ( ) , sharedInstanceRequest . getPlanId ( ) , true ) ; unshareInstance ( instanceId , false ) ; unshareInstance ( sharedInstanceId , false ) ; unbind ( 3 , instanceId , binding1Id , serviceDefinitionId , planId ) ; unbind ( 2 , instanceId , binding2Id , serviceDefinitionId , planId ) ; deleteInstance ( 2 , instanceId , serviceDefinitionId , planId , false ) ; checkCatalog ( false , true ) ; unregisterBroker ( 1 , brokerId , true ) ; String sharedBinding2Id = bind ( 1 , bindingRequest , sharedInstanceId , ServiceBrokerMockClient . TEST_BINDING_OF_SHARED_2 ) ; unshareInstance ( sharedInstanceId , true ) ; checkCatalog ( false , false ) ; unbind ( 2 , sharedInstanceId , sharedBinding1Id , sharedServiceDefinitionId , instanceId ) ; unbind ( 1 , sharedInstanceId , sharedBinding2Id , sharedServiceDefinitionId , instanceId ) ; deleteInstance ( 1 , sharedInstanceId , sharedInstanceRequest . getServiceDefinitionId ( ) , sharedInstanceRequest . getPlanId ( ) , false ) ; unregisterBroker ( 1 , brokerId , false ) ; checkCatalog ( true , false ) ; checkEmptyStorage ( ) ; }
This test fulfills a end-to-end test for sharing instances.
This test fulfills a end - to - end test for sharing instances .
// Check the availability of used services and managers // Check pre conditions // Register new service broker and check catalog afterwards // Fill values of singleton of ServiceBrokerMockClient for later use // Provision original instance and add a binding // Try to unregister broker -> should be blocked // Share original instance and check definition in catalog // Create a shared instance // Create bindings on original and shared instance // Try to delete instances with active bindings -> should be blocked // Try to unshare instances that have more than one reference -> should be blocked // Delete all bindings of original instance // Delete original instance and check catalog // Try to unregister broker after original instance was unprovisioned -> should be blocked // Create new binding on shared instance with original instance being deleted // Unshare instance // Delete bindings of shared instance // Unprovision shared instance // Unregister service broker // Check post conditions