Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions myRetailApi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,18 @@
<artifactId>jersey-apache-client</artifactId>
<version>1.19.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.8</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>projectlombok.org</id>
<url>http://projectlombok.org/mavenrepo</url>
</repository>
</repositories>
<build>
<finalName>myRetailApi</finalName>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.myRetail.product.model;

import lombok.Data;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

Expand All @@ -8,6 +10,7 @@
* </p>
*/
@XmlRootElement
@Data
public class CatalogInfo {

@XmlElement
Expand All @@ -22,27 +25,4 @@ public CatalogInfo(String id, String name) {
this.id = id;
this.name = name;
}
public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return "CatalogInfo{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
'}';
}
}
29 changes: 15 additions & 14 deletions myRetailApi/src/main/java/com/myRetail/product/model/Error.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.myRetail.product.model;

import lombok.Getter;
import lombok.Setter;

import java.util.Date;


Expand All @@ -8,29 +11,27 @@
* in processing a valid or invalid request to the APIs</p>
*/
public class Error {
@Getter
@Setter
private Date date;

@Getter
@Setter
private String message;


/**
* <p>
* Constructur - creates an instance of this class without initializing any message.
* </p>
* <i>needed for JAXB serialization</i>
*/
public Error() {}

public Error(Date d, String message ) {
this.date = d;
this.message = message;
}

public Date getDate() {
return date;
}

public void setDate(Date date) {
this.date = date;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}
}
44 changes: 11 additions & 33 deletions myRetailApi/src/main/java/com/myRetail/product/model/PriceInfo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.myRetail.product.model;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
Expand All @@ -10,16 +14,23 @@
* returned by subclasses of <code>PricingDAO</code></p>
*/
@XmlRootElement
@ToString
public class PriceInfo {

@XmlElement(name="value")
@Getter
@Setter
private float price;



@XmlElement(name="currency_code")
@Getter
@Setter
private String currencyCode;

@XmlTransient
@Setter
private String productId;

public PriceInfo() {}
Expand All @@ -30,37 +41,4 @@ public PriceInfo(String productId, float price, String currencyCode) {
this.currencyCode = currencyCode;
}

@XmlTransient
public String getProductId() {
return productId;
}

public void setProductId(String productId) {
this.productId = productId;
}

public float getPrice() {
return price;
}

public void setPrice(float price) {
this.price = price;
}

public String getCurrencyCode() {
return currencyCode;
}

public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}

@Override
public String toString() {
return "PriceInfo{" +
"price=" + price +
", currencyCode='" + currencyCode + '\'' +
", productId='" + productId + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.myRetail.product.model;

import lombok.Data;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

Expand All @@ -9,6 +11,7 @@
* the catalog information and the pricing information.
*/
@XmlRootElement
@Data
public class ProductInfo {
@XmlElement
private String id;
Expand All @@ -29,36 +32,4 @@ public ProductInfo(String id, String name, PriceInfo priceInfo){
this.priceInfo = priceInfo;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public PriceInfo getPriceInfo() {
return priceInfo;
}

public void setPriceInfo(PriceInfo priceInfo) {
this.priceInfo = priceInfo;
}

@Override
public String toString() {
return "ProductInfo{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", priceInfo=" + priceInfo +
'}';
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public ProductInfo setProductPrice(@PathParam("id")String id, ProductInfo produc
setupThreadContext(Optional.ofNullable(requestId));
List<String> errors = findErrorsInRequest(id, productInfo);
if(!errors.isEmpty()){
// String errorMessage = errors.stream().map(i -> i.toString()).collect(Collectors.joining(", "));
String errorMessage = errors.stream().collect(Collectors.joining(", "));
errorMessage = String.format("Errors found in the request :%s",errorMessage);
throw new BadRequestException(errorMessage,logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.policies.DefaultRetryPolicy;
import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;
import org.junit.After;
import org.junit.Before;
Expand Down