lierAdminKey(), serviceDetails, subDetails2);
        setDateFactory("2013-03-30 10:20:00");
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        VOSubscriptionDetails upgradedSubDetails = subscrSetup
               .upgradeSubscription(subDetails, subDetails2);

        // ASYNC
        setDateFactory("2013-04-15 10:20:00");
        subscrSetup.abortAsyncUpgradeSubscription(
                basicSetup.getSupplierAdminKey(),
                upgradedSubDetails.getSubscriptionId(),
                customer.getOrganizationId());

        // terminate Sub
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        setDateFactory("2013-04-30 10:20:00");
        subscrSetup.unsubscribeToService(subDetails.getSubscriptionId());

        resetCutOffDay(basicSetup.getSupplierAdminKey());

        BillingIntegrationTestBase.updateSubscriptionListForTests(
                "SCENARIO_39", subDetails);
        BillingIntegrationTestBase.updateSubscriptionListForTests(
                "SCENARIO_39", upgradedSubDetails);

    }

    public void createAsyncScenario40() throws Exception {
        // create subscription
        setDateFactory("2013-03-28 10:15:00");

        VOServiceDetails serviceDetails = serviceSetup
               .createPublishAndActivateMarketableService(
                        basicSetup.getSupplierAdminKey(), "SCENARIO_40",
                        TestService.EXAMPLE_ASYNC,
                        TestPriceModel.EXAMPLE_PRORATA_MONTH_ROLES_2,
                        technicalServiceAsync, supplierMarketplace);
        setCutOffDay(basicSetup.getSupplierAdminKey(), 1);
        // Create own customer
        String customerAdminId = "SCENARIO_40Customer";
        orgSetup.registerCustomer("SCENARIO_40CustomerOrg",
                TestOrganizationSetup.ORGANIZATION_DOMICILE_DE,
                customerAdminId, supplierMarketplace.getMarketplaceId(),
                basicSetup.getSupplierOrgID());

        VOUser customerAdmin = orgSetup.getUser(customerAdminId, true);

        VORoleDefinition role = VOServiceFactory.getRole(serviceDetails,
                "ADMIN");
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        VOSubscriptionDetails subDetails = subscrSetup.subscribeToService(
                "SCENARIO_40", serviceDetails, basicSetup.getCustomerUser1(),
                role);
        // ASYNC
        setDateFactory("2013-03-28 10:20:00");
        subDetails = subscrSetup.completeAsyncSubscription(
                basicSetup.getSupplierAdminKey(), customerAdmin, subDetails);

        // delete paymenttypes
        container.login(basicSetup.getSupplierAdminKey(), ROLE_SERVICE_MANAGER,
                ROLE_TECHNOLOGY_MANAGER);
        setDateFactory("2013-03-30 09:20:00");
        paymentSetup.deleteServicePaymentTypes(serviceDetails);
        subDetails = subscrSetup.getSubscriptionDetails(customerAdmin.getKey(),
                subDetails.getSubscriptionId());

        // upgrade to pro_rata of charge
        VOServiceDetails subDetails2 = serviceSetup
               .createPublishAndActivateMarketableService(
                        basicSetup.getSupplierAdminKey(), "SCENARIO_40_2",
                        TestService.EXAMPLE_ASYNC,
                        TestPriceModel.EXAMPLE_PERUNIT_MONTH_ROLES_1,
                        technicalServiceAsync, supplierMarketplace);
        serviceSetup.registerCompatibleServices(
                basicSetup.getSupplierAdminKey(), serviceDetails, subDetails2);
        setDateFactory("2013-03-30 10:20:00");
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        VOSubscriptionDetails upgradedSubDetails = subscrSetup
               .upgradeSubscription(subDetails, subDetails2);

        setDateFactory("2013-04-10 10:20:00");
        container.login(basicSetup.getSupplierAdminKey(), ROLE_SERVICE_MANAGER,
                ROLE_TECHNOLOGY_MANAGER);

        paymentSetup.reassignServicePaymentTypes(serviceDetails);

        // ASYNC
        setDateFactory("2013-04-15 10:20:00");
        upgradedSubDetails = subscrSetup.completeAsyncUpgradeSubscription(
                basicSetup.getSupplierAdminKey(), customerAdmin,
                upgradedSubDetails);

        // terminate Sub
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        setDateFactory("2013-04-30 10:20:00");
        subscrSetup.unsubscribeToService(subDetails.getSubscriptionId());

        resetCutOffDay(basicSetup.getSupplierAdminKey());

        BillingIntegrationTestBase.updateSubscriptionListForTests(
                "SCENARIO_40", subDetails);
        BillingIntegrationTestBase.updateSubscriptionListForTests(
                "SCENARIO_40", upgradedSubDetails);

    }

    public void createAsyncScenario40_1() throws Exception {
        // create subscription
        setDateFactory("2014-03-28 10:15:00");

        VOServiceDetails serviceDetails = serviceSetup
               .createPublishAndActivateMarketableService(
                        basicSetup.getSupplierAdminKey(), "SCENARIO_40_1",
                        TestService.EXAMPLE_ASYNC,
                        TestPriceModel.EXAMPLE_RATA_WEEK_ROLES,
                        technicalServiceAsync, supplierMarketplace);
        setCutOffDay(basicSetup.getSupplierAdminKey(), 1);
        // Create own customer
        String customerAdminId = "SCENARIO_40_1Customer";
        orgSetup.registerCustomer("SCENARIO_40_1CustomerOrg",
                TestOrganizationSetup.ORGANIZATION_DOMICILE_DE,
                customerAdminId, supplierMarketplace.getMarketplaceId(),
                basicSetup.getSupplierOrgID());

        VOUser customerAdmin = orgSetup.getUser(customerAdminId, true);

        VORoleDefinition role = VOServiceFactory.getRole(serviceDetails,
                "ADMIN");
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        VOSubscriptionDetails subDetails = subscrSetup.subscribeToService(
                "SCENARIO_40_1", serviceDetails, basicSetup.getCustomerUser1(),
                role);
        // ASYNC
        setDateFactory("2014-03-28 10:20:00");
        subDetails = subscrSetup.completeAsyncSubscription(
                basicSetup.getSupplierAdminKey(), customerAdmin, subDetails);

        // delete paymenttypes
        container.login(basicSetup.getSupplierAdminKey(), ROLE_SERVICE_MANAGER,
                ROLE_TECHNOLOGY_MANAGER);
        setDateFactory("2014-03-30 09:20:00");
        paymentSetup.deleteServicePaymentTypes(serviceDetails);
        subDetails = subscrSetup.getSubscriptionDetails(customerAdmin.getKey(),
                subDetails.getSubscriptionId());

        // upgrade to pro_rata of charge
        VOServiceDetails subDetails2 = serviceSetup
               .createPublishAndActivateMarketableService(
                        basicSetup.getSupplierAdminKey(), "SCENARIO_40_1_2",
                        TestService.EXAMPLE_ASYNC,
                        TestPriceModel.EXAMPLE_PERUNIT_WEEK_ROLES,
                        technicalServiceAsync, supplierMarketplace);
        serviceSetup.registerCompatibleServices(
                basicSetup.getSupplierAdminKey(), serviceDetails, subDetails2);
        setDateFactory("2014-03-30 10:20:00");
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        VOSubscriptionDetails upgradedSubDetails = subscrSetup
               .upgradeSubscription(subDetails, subDetails2);

        // ASYNC
        setDateFactory("2014-03-31 10:20:00");
        upgradedSubDetails = subscrSetup.completeAsyncUpgradeSubscription(
                basicSetup.getSupplierAdminKey(), customerAdmin,
                upgradedSubDetails);

        // terminate Sub
        container.login(customerAdmin.getKey(), ROLE_ORGANIZATION_ADMIN);
        setDateFactory("2014