@Test public void getProductsForVendor_FilterInStatuses() throws Exception { // give givenBrokerOrg(); container.login(brokerUserKey, UserRoleType.BROKER_MANAGER.name()); Product templateInactive = createTemplateProduct( broker.getOrganizationId(), "productInactive", "techProductInactive", ServiceStatus.INACTIVE); Product templateActive = createTemplateProduct( broker.getOrganizationId(), "productActive", "techProductActive", ServiceStatus.ACTIVE); createTemplateProduct( broker.getOrganizationId(), "productDeleted", "techProductDeleted", ServiceStatus.DELETED); createTemplateProduct( broker.getOrganizationId(), "productObsolete", "techProductObsolete", ServiceStatus.OBSOLETE); Product templateSuspended = createTemplateProduct( broker.getOrganizationId(), "productSuspended", "techProductSuspended", ServiceStatus.SUSPENDED); // when List<Product> products = runTX( new Callable<List<Product>>() { public List<Product> call() { return localService.getProductsForVendor(); } }); // then assertEquals(3, products.size()); assertEquals(templateInactive.getKey(), products.get(0).getKey()); assertEquals(ServiceStatus.INACTIVE, products.get(0).getStatus()); assertEquals(templateActive.getKey(), products.get(1).getKey()); assertEquals(ServiceStatus.ACTIVE, products.get(1).getStatus()); assertEquals(ServiceStatus.SUSPENDED, products.get(2).getStatus()); assertEquals(templateSuspended.getKey(), products.get(2).getKey()); }
@Test public void getProductsForVendor_NoServices() throws Exception { // given givenBrokerOrg(); container.login(brokerUserKey, UserRoleType.BROKER_MANAGER.name()); // when List<Product> products = runTX( new Callable<List<Product>>() { public List<Product> call() { return localService.getProductsForVendor(); } }); // then assertEquals(0, products.size()); }
@Test public void getProductsForVendor_WithSubscriptionSpecificCopy() throws Exception { // given givenBrokerOrg(); container.login(brokerUserKey, UserRoleType.BROKER_MANAGER.name()); Product template = createTemplateProduct( broker.getOrganizationId(), "product", "techProduct", ServiceStatus.ACTIVE); createSubscriptionSpecificProductCopy(broker, template); // when List<Product> products = runTX( new Callable<List<Product>>() { public List<Product> call() { return localService.getProductsForVendor(); } }); // then assertEquals(1, products.size()); }