Package com.ibm.sbt.services.client.base

Examples of com.ibm.sbt.services.client.base.JsonEntity


    public void testGetSubscriptionById() {
      try {
        SubscriptionManagementService subscriptionManagement = getSubscriptionManagementService();
        EntityList<JsonEntity> subscriptionList = subscriptionManagement.getSubscriptions();
        if (!subscriptionList.isEmpty()) {
          JsonEntity subscription = subscriptionList.get(0);
          long id = subscription.getAsLong("Id");
         
          subscription = subscriptionManagement.getSubscriptionById("" + id);
          System.out.println(subscription.toJsonString(false));
          Assert.assertNotNull("Unable to retrieve subscription: "+id, subscription);
          Assert.assertEquals(""+id, getSubscriptionManagementService().getSubscriptionId(subscription.getJsonObject()));
        }
      } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Error retrieving subscription caused by: "+e.getMessage());       
      }
View Full Code Here


        registerCustomer();
        String subscriptionId = createSubscription();
       
        SubscriptionManagementService subscriptionManagement = getSubscriptionManagementService();
       
        JsonEntity jsonEntity = subscriptionManagement.getSubscriptionById(subscriptionId);
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, jsonEntity);
      System.out.println(jsonEntity.toJsonString());
     
      Assert.assertEquals(subscriptionId, subscriptionManagement.getSubscriptionId(jsonEntity.getJsonObject()));

      JsonJavaObject rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, rootObject);
     
      subscriptionManagement.suspendSubscription(subscriptionId);
     
      jsonEntity = subscriptionManagement.getSubscriptionById(subscriptionId);
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, jsonEntity);
      Assert.assertEquals(subscriptionId, subscriptionManagement.getSubscriptionId(jsonEntity.getJsonObject()));
     
      rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, rootObject);
     
      System.out.println(rootObject);
      JsonJavaObject subscriptionObject = rootObject.getAsObject("Subscription");
      System.out.println(subscriptionObject);
View Full Code Here

        registerCustomer();
        String subscriptionId = createSubscription();
       
        SubscriptionManagementService subscriptionManagement = getSubscriptionManagementService();
       
        JsonEntity jsonEntity = subscriptionManagement.getSubscriptionById(subscriptionId);
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, jsonEntity);
      Assert.assertEquals(subscriptionId, subscriptionManagement.getSubscriptionId(jsonEntity.getJsonObject()));

      JsonJavaObject rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, rootObject);
     
      subscriptionManagement.suspendSubscription(subscriptionId);
     
      jsonEntity = subscriptionManagement.getSubscriptionById(subscriptionId);
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, jsonEntity);
      Assert.assertEquals(subscriptionId, subscriptionManagement.getSubscriptionId(jsonEntity.getJsonObject()));
     
      rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, rootObject);
     
      System.out.println(rootObject);
      JsonJavaObject subscriptionObject = rootObject.getAsObject("Subscription");
      System.out.println(subscriptionObject);
      Assert.assertEquals("SUSPENDED", subscriptionObject.get("SubscriptionState"));
     
      subscriptionManagement.unsuspendSubscription(subscriptionId);
     
      jsonEntity = subscriptionManagement.getSubscriptionById(subscriptionId);
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, jsonEntity);
      Assert.assertEquals(subscriptionId, subscriptionManagement.getSubscriptionId(jsonEntity.getJsonObject()));
     
      rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscription: "+subscriptionId, rootObject);
     
      System.out.println(rootObject);
      subscriptionObject = rootObject.getAsObject("Subscription");
      System.out.println(subscriptionObject);
View Full Code Here

        long begin = System.currentTimeMillis();
        for (int i=0; i<1000; i++) {
          try {
              // Add Subscriber
              String subscriberId = addSubscriber(customerId);
              JsonEntity subscriber = getSubscriberById(subscriberId);
              String loginName = subscriber.getAsString("Subscriber/Person/EmailAddress");
     
              // Activate the subscriber
              activateSubscriber(subscriberId);             
              waitSubscriberActive(subscriberId);
             
View Full Code Here

    @Test
    public void testUnassignRole() {
      try {
        String subscriberId = addSubscriber();
        JsonEntity subscriber = getSubscriberById(subscriberId);
        String loginName = subscriber.getAsString("Subscriber/Person/EmailAddress");
        System.out.println(loginName);
       
        AuthorizationService authorizationService = getAuthorizationService();
        authorizationService.assignRole(loginName, "CustomerAdministrator");
        authorizationService.assignRole(loginName, "CustomerPurchaser");
View Full Code Here

        registerCustomer();
        String subscriberId = addSubscriber();
       
        SubscriberManagementService subscriberManagement = getSubscriberManagementService();
       
        JsonEntity jsonEntity = subscriberManagement.getSubscriberById(subscriberId);
      Assert.assertNotNull("Unable to retrieve subscriber: "+subscriberId, jsonEntity);
      Assert.assertEquals(subscriberId, subscriberManagement.getSubscriberId(jsonEntity.getJsonObject()));

      JsonJavaObject rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscriber: "+subscriberId, rootObject);
     
      System.out.println(rootObject);
      JsonJavaObject subscriberObject = rootObject.getAsObject("Subscriber");
      JsonJavaObject personObject = subscriberObject.getAsObject("Person");
      personObject.putString("GivenName", "Fred");
      personObject.putString("WorkPhone", "800-666-1234");
     
      subscriberManagement.updateSubscribeProfile(rootObject);
     
      jsonEntity = subscriberManagement.getSubscriberById(subscriberId);
      Assert.assertNotNull("Unable to retrieve subscriber: "+subscriberId, jsonEntity);
      Assert.assertEquals(subscriberId, subscriberManagement.getSubscriberId(jsonEntity.getJsonObject()));
     
      rootObject = jsonEntity.getJsonObject();
      Assert.assertNotNull("Unable to retrieve subscriber: "+subscriberId, subscriberObject);
     
      System.out.println(rootObject);
      subscriberObject = rootObject.getAsObject("Subscriber");
      personObject = subscriberObject.getAsObject("Person");
View Full Code Here

        // prevent deletion
        setCustomerId(null);

        // Step 2. Add Subscriber
      String subscriberId = addAdministrator(customerId);
        JsonEntity administrator = getSubscriberById(subscriberId);
        System.out.println(administrator.toJsonString());
        String loginName = administrator.getAsString("Subscriber/Person/EmailAddress");
        setPassword(loginName, "onet1me!", "passw0rd");
        System.out.println(loginName);

        // Step 3. Create "IBM SmartCloud Connections" Subscription
        String engageSubscriptionId = createSubscription(customerId, 3, "D0NWLLL", 5);
        System.out.println(engageSubscriptionId);
        System.out.println("D0NWLLL : " + getSubscriptionById(engageSubscriptionId).toJsonString());

        // Step 4. Create Extra Storage Subscription
        String storageSubscriptionId = createSubscription(customerId, 3, "D100PLL", 100);
        System.out.println(storageSubscriptionId);
        System.out.println("D100PLL : " + getSubscriptionById(storageSubscriptionId).toJsonString());

        // Step 5. Activate the subscriber
        activateSubscriber(subscriberId);
       
        // Step 8. Entitle subscriber
        entitleSubscriber(subscriberId, engageSubscriptionId, true);
        entitleSubscriber(subscriberId, storageSubscriptionId, true);
       
        // Optional: Check seats
        JsonEntity jsonEntity = getSubscriberManagementService().getSubscriberById(subscriberId);
        JsonJavaObject rootObject = jsonEntity.getJsonObject();
        JsonJavaObject subscriberObject = rootObject.getAsObject("Subscriber");
      List<Object> seatSet = subscriberObject.getAsList("SeatSet");
        for (Object seat : seatSet) {
          System.out.println(seat);
        }
       
        // Step 8. Retrieve a seat
        JsonJavaObject seatJson = findSeat(subscriberId, storageSubscriptionId);
        String seatId = String.valueOf(seatJson.getAsObject("Seat").getAsLong("Id"));

        // Step 9. Revoke subscriber subscription
        getSubscriberManagementService().revokeSubscriber(subscriberId, seatId, true);
       
        // Optional: Check seats
        jsonEntity = getSubscriberManagementService().getSubscriberById(subscriberId);
        rootObject = jsonEntity.getJsonObject();
        subscriberObject = rootObject.getAsObject("Subscriber");
      seatSet = subscriberObject.getAsList("SeatSet");
        for (Object seat : seatSet) {
          System.out.println(seat);
        }
View Full Code Here

        entitleSubscriber(subscriberId, storageSubscriptionId, true);
        */
       
        // Revoke subscriptions
        JsonEntity jsonEntity = getSubscriberManagementService().getSubscriberById(subscriberId);
        JsonJavaObject rootObject = jsonEntity.getJsonObject();
        JsonJavaObject subscriberObject = rootObject.getAsObject("Subscriber");
      List<Object> seatSet = subscriberObject.getAsList("SeatSet");
        for (Object seat : seatSet) {
          System.out.println(seat);
          JsonJavaObject seatJson = (JsonJavaObject)seat;
          String seatId = String.valueOf(seatJson.getAsLong("Id"));
          String subscriptionId = String.valueOf(seatJson.getAsLong("SubscriptionId"));

            getSubscriberManagementService().revokeSubscriber(subscriberId, seatId, true);
        }
       
        // Optional: Check seats
        jsonEntity = getSubscriberManagementService().getSubscriberById(subscriberId);
        rootObject = jsonEntity.getJsonObject();
        subscriberObject = rootObject.getAsObject("Subscriber");
      seatSet = subscriberObject.getAsList("SeatSet");
        for (Object seat : seatSet) {
          System.out.println(seat);
        }
View Full Code Here

        // Step 8. Entitle subscriber
        entitleSubscriber(subscriberId, engageSubscriptionId, true);
        entitleSubscriber(subscriberId, storageSubscriptionId, true);

        // Optional: Check seats
        JsonEntity jsonEntity = getSubscriberManagementService().getSubscriberById(subscriberId);
        JsonJavaObject rootObject = jsonEntity.getJsonObject();
        JsonJavaObject subscriberObject = rootObject.getAsObject("Subscriber");
      List<Object> seatSet = subscriberObject.getAsList("SeatSet");
        for (Object seat : seatSet) {
          System.out.println(seat);
        }
       
        // Step 8. Retrieve a seat
        JsonJavaObject seatJson = findSeat(subscriberId, storageSubscriptionId);
        String seatId = String.valueOf(seatJson.getAsObject("Seat").getAsLong("Id"));
        JsonEntity seatEntity = getSeat(storageSubscriptionId, seatId);

        // Step 9. Change quota
        seatJson = seatEntity.getJsonObject();
        seatJson.getAsObject("Seat").putInt("EntitlementQuantityAllocated", 25);
        getSubscriptionManagementService().changeQuota(storageSubscriptionId, seatId, seatJson);
       
        // Optional: Check seats
        jsonEntity = getSubscriberManagementService().getSubscriberById(subscriberId);
View Full Code Here

        }
      };
      subscriptionManagement.waitSubscriptionState(engageSubscriptionId, "ACTIVE" , 5, 1000, stateChangeListener);

        String subscriberId = addSubscriber(customerId);
        JsonEntity subscriber = getSubscriberById(subscriberId);
        String loginName = subscriber.getAsString("Subscriber/Person/EmailAddress");
        System.out.println(loginName);
       
      AuthorizationService authorizationService = getAuthorizationService();
        authorizationService.assignRole(loginName, "CustomerAdministrator");
        authorizationService.assignRole(loginName, "VSR");
        String[] roles = authorizationService.getRoles(loginName);
      Assert.assertTrue(arrayContains("User", roles));
      Assert.assertTrue(arrayContains("CustomerAdministrator", roles));
      Assert.assertTrue(arrayContains("VSR", roles));
     
      activateSubscriber(subscriberId);
      setPassword(loginName, "onet1me!", "passw0rd");
     
      entitleSubscriber(subscriberId, engageSubscriptionId, true, false);

      //getSubscriberManagementService().waitSeatState(subscriberId, engageSubscriptionId, "ASSIGNED", 10, 2000, null);
      long start = System.currentTimeMillis();
        for (int i=0; i<100; i++) {
          JsonJavaObject seatJson = findSeat(subscriberId, engageSubscriptionId);
          if (seatJson != null) {
            System.out.println(seatJson.toString());
              String currentState = seatJson.getAsObject("Seat").getAsString("SeatState");
              System.out.println("SeatState:"+currentState);
              if ("ASSIGNED".equalsIgnoreCase(currentState)) {
                break;
              }
          }
         
          // wait the specified interval
        try {
          Thread.sleep(2000);
        } catch (InterruptedException ie) {}
        }
        long duration = System.currentTimeMillis() - start;
        System.out.println("Wait for seat took: " + duration);

      subscriber = getSubscriberManagementService().getSubscriberById(subscriberId);
      System.out.println(subscriber.toJsonString());
     
      } catch (BssException be) {
        JsonJavaObject jsonObject = be.getResponseJson();
        System.err.println(jsonObject);
        Assert.fail("Error retrieving roles caused by: "+jsonObject);
View Full Code Here

TOP

Related Classes of com.ibm.sbt.services.client.base.JsonEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.