use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class OrderBaseTest method setUpCartWithActiveSku.
public Order setUpCartWithActiveSku() throws AddToCartException {
Customer customer = customerService.saveCustomer(createNamedCustomer());
Order order = orderService.createNewCartForCustomer(customer);
Product newProduct = addTestProduct("Plastic Crate Active", "Crates");
Category newCategory = newProduct.getDefaultCategory();
order = orderService.addItem(order.getId(), new OrderItemRequestDTO(newProduct.getId(), newProduct.getDefaultSku().getId(), newCategory.getId(), 1), true);
return order;
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class OrderBaseTest method setUpCartWithInactiveSku.
public Order setUpCartWithInactiveSku() throws AddToCartException {
Customer customer = customerService.saveCustomer(createNamedCustomer());
Order order = orderService.createNewCartForCustomer(customer);
Product newProduct = addTestProduct("Plastic Crate Should Be Inactive", "Crates");
Category newCategory = newProduct.getDefaultCategory();
order = orderService.addItem(order.getId(), new OrderItemRequestDTO(newProduct.getId(), newProduct.getDefaultSku().getId(), newCategory.getId(), 1), true);
// Make the SKU inactive
newProduct.getDefaultSku().setActiveEndDate(DateUtils.addDays(new Date(), -1));
catalogService.saveSku(newProduct.getDefaultSku());
return order;
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class TranslationServiceTest method testTranslation.
@Test(groups = { "testTranslation" })
@Transactional
public void testTranslation() throws Exception {
Category category = new CategoryImpl();
category.setName("Translation");
category = catalogService.saveCategory(category);
translationService.save(TranslatedEntity.CATEGORY.getType(), String.valueOf(category.getId()), "name", "es_MX", "es_MX");
translationService.save(TranslatedEntity.CATEGORY.getType(), String.valueOf(category.getId()), "name", "es", "es");
String specificTranslation = translationService.getTranslatedValue(category, "name", new Locale("es", "MX"));
Assert.assertEquals(specificTranslation, "es_MX");
String generalTranslation = translationService.getTranslatedValue(category, "name", Locale.forLanguageTag("es"));
Assert.assertEquals(generalTranslation, "es");
// test a second time to go through cache
specificTranslation = translationService.getTranslatedValue(category, "name", new Locale("es", "MX"));
Assert.assertEquals(specificTranslation, "es_MX");
generalTranslation = translationService.getTranslatedValue(category, "name", Locale.forLanguageTag("es"));
Assert.assertEquals(generalTranslation, "es");
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class CategoryDaoDataProvider method provideBasicCategory.
@DataProvider(name = "basicCategory")
public static Object[][] provideBasicCategory() {
Category category = new CategoryImpl();
category.setName("Yuban");
category.setDescription("Yuban");
category.setId(1001L);
return new Object[][] { { category } };
}
use of org.broadleafcommerce.core.catalog.domain.Category in project BroadleafCommerce by BroadleafCommerce.
the class CategoryParentCategoryFieldPersistenceProvider method checkDirtyState.
protected boolean checkDirtyState(Category instance, Long checkValue) {
boolean dirty = !(instance == null && checkValue == null) && (instance == null || checkValue == null);
if (!dirty) {
Long value = null;
Category category = getDefaultCategory(instance);
if (category != null) {
value = category.getId();
}
dirty = value == null || !value.equals(checkValue);
}
return dirty;
}
Aggregations