Initial proposal for
Initial Proposal for
@@ -57,6 +57,17 @@ public class CatalogUpdater {
public static String DEFAULT_CATALOG_NAME = "DEFAULT";
+ public static String INVALID_PLAN = "Plan doesn't exist or Plan is Invalid.";
+
+ public static String INVALID_PRODUCT_NAME = "Product Name doesnt exist. Please provide valid Product Name.";
+
+ public static String INVALID_PRICE = "Please check Amount and Currency. Amount should be greater than 0 and currency should be valid.";
+
+ public static String BASE_PLAN_PRODUCTS_NOT_EMPTY = "Base Plan Products should not be empty.";
+
+ public static String EXISTING_PRODUCTS_NOT_EMPTY = "Existing current product should not be empty.";
+
+
private final DefaultMutableStaticCatalog catalog;
public CatalogUpdater(final StandaloneCatalog standaloneCatalog) {
@@ -109,12 +120,12 @@ public class CatalogUpdater {
// We need at least a planId
if (desc == null || desc.getPlanId() == null) {
- throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, desc);
+ throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR , INVALID_PLAN);
}
DefaultPlan plan = (DefaultPlan) getExistingPlan(desc.getPlanId());
if (plan == null && desc.getProductName() == null) {
- throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, desc);
+ throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, INVALID_PRODUCT_NAME);
}
validateNewPlanDescriptor(desc);
@@ -287,16 +298,16 @@ public class CatalogUpdater {
final boolean invalidPrice = (desc.getAmount() == null || desc.getAmount().compareTo(BigDecimal.ZERO) < 0) ||
desc.getCurrency() == null;
if (invalidPlan || invalidPrice) {
- throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, desc);
+ throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, INVALID_PRICE);
}
if (desc.getProductCategory() == ProductCategory.ADD_ON) {
if (desc.getAvailableBaseProducts() == null || desc.getAvailableBaseProducts().isEmpty()) {
- throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, desc);
+ throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, BASE_PLAN_PRODUCTS_NOT_EMPTY);
}
for (final String cur : desc.getAvailableBaseProducts()) {
if (getExistingProduct(cur) == null) {
- throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, desc);
+ throw new CatalogApiException(ErrorCode.CAT_INVALID_SIMPLE_PLAN_DESCRIPTOR, EXISTING_PRODUCTS_NOT_EMPTY);
}
}
}
