private Product createService() { Product prod = new Product(); prod.setKey(SERVICE_ID); prod.setProductId(SERVICE_NAME); prod.setTemplate(prod); return prod; }
private Product givenService() { Product prod = new Product(); prod.setKey(PRODUCT_KEY); prod.setProductId(PRODUCT_ID); prod.setTemplate(prod); return prod; }
@Before public void setUp() { LocalizerServiceStub localizerServiceStub = new LocalizerServiceStub() { @Override public String getLocalizedTextFromDatabase( String localeString, long objectKey, LocalizedObjectTypes objectType) { return localizedText; } }; facade = new LocalizerFacade(localizerServiceStub, Locale.GERMAN.getLanguage()); // server side entries Product product = new Product(); product.setKey(PRODUCT_KEY); product.setTechnicalProduct(new TechnicalProduct()); product.setAutoAssignUserEnabled(false); ProductFeedback feedback = new ProductFeedback(); feedback.setAverageRating(new BigDecimal("2.5")); product.setProductFeedback(feedback); mp = new Marketplace(); mp.setKey(1); mp.setMarketplaceId(MP_ID); mp.setOrganization(new Organization()); catalogEntry = new CatalogEntry(); catalogEntry.setKey(1); catalogEntry.setProduct(product); catalogEntry.setMarketplace(mp); catalogEntry.setAnonymousVisible(true); catalogEntry.setVisibleInCatalog(true); catalogEntry2 = new CatalogEntry(); catalogEntry2.setKey(2); catalogEntry3 = new CatalogEntry(); catalogEntry3.setKey(3); VOMarketplace voMp = new VOMarketplace(); voMp.setMarketplaceId(MP_ID); // incoming entries voCatalogEntry = new VOCatalogEntry(); voCatalogEntry.setKey(1); voCatalogEntry.setVersion(0); voCatalogEntry.setMarketplace(voMp); voCatalogEntry.setAnonymousVisible(true); voCatalogEntry.setVisibleInCatalog(true); voCatalogEntry2 = new VOCatalogEntry(); voCatalogEntry2.setKey(2); voCatalogEntry3 = new VOCatalogEntry(); voCatalogEntry3.setKey(3); }
private List<Product> givenProducts() { List<Product> products = new ArrayList<Product>(); Product product1 = new Product(); product1.setKey(PRODUCTKEY_1); product1.setProductId(PRODUCTID_1); Organization org1 = new Organization(); org1.setOrganizationId(VENDORID_1); product1.setVendor(org1); Product product2 = new Product(); product2.setProductId(PRODUCTID_2); product2.setKey(PRODUCTKEY_2); Organization org2 = new Organization(); org2.setOrganizationId(VENDORID_2); product2.setVendor(org2); products.add(product1); products.add(product2); return products; }
@Test public void getProductName() throws Exception { // given List<Product> products = new ArrayList<Product>(); Product prod = new Product(); prod.setKey(1000L); products.add(prod); givenProductName(); // when Map<Long, String> result = logCollector.getProductName(dsMock, products); // then assertEquals(1, result.size()); assertEquals(PRODUCTNAME, result.get(Long.valueOf(1000L))); }
@Before public void setup() throws Exception { ds = mock(DataService.class); pt = new PaymentType(); pt.setPaymentTypeId(PaymentType.INVOICE); pt.setKey(12345); Organization op = new Organization(); op.setOrganizationId(OrganizationRoleType.PLATFORM_OPERATOR.name()); supplier = new Organization(); supplier.setOrganizationId("supplier"); Organizations.grantOrganizationRole(supplier, OrganizationRoleType.SUPPLIER); reseller = new Organization(); reseller.setOrganizationId("reseller"); Organizations.grantOrganizationRole(reseller, OrganizationRoleType.RESELLER); OrganizationReference ref = OrganizationReferences.addReference( op, supplier, OrganizationReferenceType.PLATFORM_OPERATOR_TO_SUPPLIER); OrganizationReferences.enablePayment(ref, pt) .setOrganizationRole(new OrganizationRole(OrganizationRoleType.SUPPLIER)); ref = OrganizationReferences.addReference( op, reseller, OrganizationReferenceType.PLATFORM_OPERATOR_TO_RESELLER); OrganizationReferences.enablePayment(ref, pt) .setOrganizationRole(new OrganizationRole(OrganizationRoleType.RESELLER)); customer = new Organization(); customer.setOrganizationId("customer"); noCustomer = new Organization(); noCustomer.setOrganizationId("noCustomer"); ref = OrganizationReferences.addReference( supplier, customer, OrganizationReferenceType.SUPPLIER_TO_CUSTOMER); OrganizationReferences.enablePayment(ref, pt); ref = OrganizationReferences.addReference( reseller, customer, OrganizationReferenceType.RESELLER_TO_CUSTOMER); OrganizationReferences.enablePayment(ref, pt); product = new Product(); product.setKey(9876); product.setVendor(supplier); product.setType(ServiceType.TEMPLATE); product.setPaymentTypes(Arrays.asList(new ProductToPaymentType(product, pt))); pcf = new PaymentConfigurationFilter(ds); user = new PlatformUser(); user.setOrganization(supplier); when(ds.getCurrentUser()).thenReturn(user); when(ds.getReference(eq(Product.class), eq(product.getKey()))).thenReturn(product); when(ds.getReference(eq(Product.class), eq(PROD_NOT_FOUND_KEY))) .thenThrow(new ObjectNotFoundException(ClassEnum.SERVICE, "product")); when(ds.getReferenceByBusinessKey(any(DomainObject.class))) .thenAnswer( new Answer<DomainObject<?>>() { public DomainObject<?> answer(InvocationOnMock invocation) throws Throwable { Object object = invocation.getArguments()[0]; if (object instanceof Organization) { Organization o = (Organization) object; if (customer.getOrganizationId().equals(o.getOrganizationId())) { return customer; } if (noCustomer.getOrganizationId().equals(o.getOrganizationId())) { return noCustomer; } throw new ObjectNotFoundException(ClassEnum.ORGANIZATION, o.getOrganizationId()); } throw new ObjectNotFoundException( ClassEnum.ORGANIZATION, object.getClass().getName()); } }); }