Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,29 @@ public class ConstructorItem {
private String imageUrl;
private String id;
private String description;
private Boolean active = true;
private Map<String, List<Object>> facets;
private Map<String, Object> metadata;
private List<String> groupIds;

public ConstructorItem(String id, String name, Boolean active) throws IllegalArgumentException {
if (id == null) {
throw new IllegalArgumentException("id is required");
}

this.id = id;
this.name = name;
this.active = active;
this.suggestedScore = null;
this.keywords = null;
this.url = null;
this.imageUrl = null;
this.description = null;
this.facets = null;
this.metadata = null;
this.groupIds = null;
}

/**
* Creates an item. Optional public fields are in the <a
* href="https://docs.constructor.com/reference/catalog-items">API documentation</a>
Expand Down Expand Up @@ -171,6 +190,16 @@ public void setDescription(String description) {
this.description = description;
}

/**
* @return the active
*/
public Boolean getActive() { return active; }

/**
* @param active the active to set
*/
public void setActive(Boolean active) { this.active = active; }

/**
* @return the id
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,28 @@ public void createOrReplaceItemsShouldReturnAResponseWithAllParameters() throws
addItemsToCleanUpArray(items);
}

@Test
public void createOrReplaceItemsShouldRespectActiveFlag() throws Exception
{
ConstructorIO constructor = new ConstructorIO(token, apiKey, true, null);

ConstructorItem item = Utils.createProductItem();
item.setActive(true);

constructor.createOrReplaceItems(new ConstructorItem[]{item}, "Products");

Thread.sleep(2000);

ItemsRequest request = new ItemsRequest();
request.setIds(Arrays.asList(item.getId()));
ItemsResponse response = constructor.retrieveItems(request);

assertTrue("Item should exist", response.getTotalCount() >= 1);
assertTrue("Item should be active", response.getItems().get(0).getActive());

addItemsToCleanUpArray(new ConstructorItem[]{item});
}

@Test
public void updateItemsShouldReturnAResponse() throws Exception {
ConstructorIO constructor = new ConstructorIO(token, apiKey, true, null);
Expand Down