Skip to content

Commit

Permalink
kontent-ai#48 Missed the null condition, adding to PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
aweigold committed Feb 6, 2018
1 parent a6115e1 commit e060701
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/kenticocloud/delivery/DeliveryClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ private void addTypeParameterIfNecessary(Class tClass, List<NameValuePair> param
.findAny();
if (!any.isPresent()) {
String contentType = stronglyTypedContentItemConverter.getContentType(tClass);
params.add(new BasicNameValuePair("system.type", contentType));
if (contentType != null) {
params.add(new BasicNameValuePair("system.type", contentType));
}
}
}

Expand Down
19 changes: 14 additions & 5 deletions src/test/java/com/kenticocloud/delivery/DeliveryClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,20 @@ public void testGetStronglyTypedItemByRegisteringType() throws Exception {

this.serverBootstrap.registerHandler(
String.format("/%s/%s", projectId, "items/on_roasts"),
(request, response, context) -> response.setEntity(
new InputStreamEntity(
this.getClass().getResourceAsStream("SampleContentItem.json")
)
));
(request, response, context) -> {
String uri = String.format("http://testserver%s", request.getRequestLine().getUri());

List<NameValuePair> nameValuePairs =
URLEncodedUtils.parse(URI.create(uri), Charset.defaultCharset());
Assert.assertFalse(nameValuePairs.stream()
.anyMatch(nameValuePair -> nameValuePair.getName().equals("system.type")));

response.setEntity(
new InputStreamEntity(
this.getClass().getResourceAsStream("SampleContentItem.json")
)
);
});
HttpHost httpHost = this.start();
DeliveryClient client = new DeliveryClient(projectId);
client.registerType("article", ArticleItem.class);
Expand Down

0 comments on commit e060701

Please sign in to comment.