@Test public void testUnregisterCustomers() { try { CustomerManagementService customerManagement = getCustomerManagementService(); EntityList<JsonEntity> customerList = customerManagement.getCustomers(); for (JsonEntity customer : customerList) { String customerId = "" + customer.getAsLong("Id"); String customerType = customer.getAsString("CustomerType"); if (!"RESELLER".equals(customerType)) { try { System.out.println("Unregistering: " + customerId); customerManagement.unregisterCustomer(customerId); JsonEntity jsonEntity = customerManagement.getCustomerById(customerId); Assert.assertNull("Able to retrieve unregistered customer: " + customerId, jsonEntity); System.out.println("Unregistered: " + customerId); } catch (BssException be) { JsonJavaObject jsonObject = be.getResponseJson(); System.out.println(jsonObject); Assert.fail("Error unregistering customer caused by: " + jsonObject); } } } } catch (Exception e) { e.printStackTrace(); Assert.fail("Error unregistering customers caused by: " + e.getMessage()); } }
@Test public void testSuspendCustomer() { try { String customerId = registerCustomer(); CustomerManagementService customerManagement = getCustomerManagementService(); JsonEntity jsonEntity = customerManagement.getCustomerById(customerId); Assert.assertNotNull("Unable to retrieve customer: " + customerId, jsonEntity); Assert.assertEquals(customerId, customerManagement.getCustomerId(jsonEntity.getJsonObject())); customerManagement.suspendCustomer(customerId); jsonEntity = customerManagement.getCustomerById(customerId); Assert.assertNotNull("Unable to retrieve customer: " + customerId, jsonEntity); JsonJavaObject rootObject = jsonEntity.getJsonObject(); JsonJavaObject customerObject = rootObject.getAsObject("Customer"); System.out.println(customerObject); Assert.assertNotNull("No SuspensionDate", customerObject.get("SuspensionDate")); customerManagement.unsuspendCustomer(customerId); jsonEntity = customerManagement.getCustomerById(customerId); Assert.assertNotNull("Unable to retrieve customer: " + customerId, jsonEntity); rootObject = jsonEntity.getJsonObject(); customerObject = rootObject.getAsObject("Customer"); System.out.println(customerObject); Assert.assertNull("SuspensionDate", customerObject.get("SuspensionDate")); Assert.assertEquals("ACTIVE", customerObject.get("CustomerState")); } catch (BssException be) { JsonJavaObject jsonObject = be.getResponseJson(); System.out.println(jsonObject); Assert.fail("Error suspending customer caused by: " + jsonObject); } catch (Exception e) { e.printStackTrace(); Assert.fail("Error suspending customer caused by: " + e.getMessage()); } }