-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sebastian Warnke
committed
Dec 3, 2017
0 parents
commit 6c8f9e5
Showing
5 changed files
with
308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_STORE | ||
target | ||
.project | ||
.settings | ||
.classpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>de.sebwarnke.alexa.skills</groupId> | ||
<artifactId>selfoss</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>1.7.25</version> | ||
</dependency> | ||
<dependency> | ||
<!-- use logback as logger --> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.1.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.camunda.consulting</groupId> | ||
<artifactId>simplerestclient</artifactId> | ||
<version>0.4.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<repositories> | ||
<repository> | ||
<id>camunda</id> | ||
<name>Camunda</name> | ||
<url>https://app.camunda.com/nexus/content/groups/public</url> | ||
</repository> | ||
</repositories> | ||
</project> |
29 changes: 29 additions & 0 deletions
29
src/main/java/de/sebwarnke/restwrapper/selfoss/SelfossWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.sebwarnke.restwrapper.selfoss; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.camunda.consulting.simplerestclient.RestClient; | ||
import com.camunda.consulting.simplerestclient.request.Request; | ||
import com.camunda.consulting.simplerestclient.response.ResponseWithBody; | ||
|
||
import de.sebwarnke.restwrapper.selfoss.model.Article; | ||
|
||
public class SelfossWrapper { | ||
|
||
private RestClient restClient; | ||
|
||
public SelfossWrapper() { | ||
restClient = new RestClient("https://reader.halephan.com"); | ||
} | ||
|
||
public List<Article> getArticles() { | ||
List<Article> result = new ArrayList<Article>(); | ||
|
||
Request request = restClient.newRequest("items"); | ||
ResponseWithBody<Article> response = restClient.get(request, Article.class); | ||
|
||
result = response.getResults(); | ||
return result; | ||
} | ||
} |
200 changes: 200 additions & 0 deletions
200
src/main/java/de/sebwarnke/restwrapper/selfoss/model/Article.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
package de.sebwarnke.restwrapper.selfoss.model; | ||
|
||
import java.io.Serializable; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@SuppressWarnings("serial") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class Article implements Serializable { | ||
|
||
@JsonProperty("id") | ||
private String id; | ||
@JsonProperty("datetime") | ||
private String datetime; | ||
@JsonProperty("title") | ||
private String title; | ||
@JsonProperty("content") | ||
private String content; | ||
@JsonProperty("unread") | ||
private String unread; | ||
@JsonProperty("starred") | ||
private String starred; | ||
@JsonProperty("source") | ||
private String source; | ||
@JsonProperty("thumbnail") | ||
private String thumbnail; | ||
@JsonProperty("icon") | ||
private String icon; | ||
@JsonProperty("uid") | ||
private String uid; | ||
@JsonProperty("link") | ||
private String link; | ||
@JsonProperty("updatetime") | ||
private String updatetime; | ||
@JsonProperty("author") | ||
private String author; | ||
@JsonProperty("sourcetitle") | ||
private String sourcetitle; | ||
@JsonProperty("tags") | ||
private String tags; | ||
|
||
@JsonProperty("id") | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@JsonProperty("id") | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
@JsonProperty("datetime") | ||
public String getDatetime() { | ||
return datetime; | ||
} | ||
|
||
@JsonProperty("datetime") | ||
public void setDatetime(String datetime) { | ||
this.datetime = datetime; | ||
} | ||
|
||
@JsonProperty("title") | ||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
@JsonProperty("title") | ||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
@JsonProperty("content") | ||
public String getContent() { | ||
return content; | ||
} | ||
|
||
@JsonProperty("content") | ||
public void setContent(String content) { | ||
this.content = content; | ||
} | ||
|
||
@JsonProperty("unread") | ||
public String getUnread() { | ||
return unread; | ||
} | ||
|
||
@JsonProperty("unread") | ||
public void setUnread(String unread) { | ||
this.unread = unread; | ||
} | ||
|
||
@JsonProperty("starred") | ||
public String getStarred() { | ||
return starred; | ||
} | ||
|
||
@JsonProperty("starred") | ||
public void setStarred(String starred) { | ||
this.starred = starred; | ||
} | ||
|
||
@JsonProperty("source") | ||
public String getSource() { | ||
return source; | ||
} | ||
|
||
@JsonProperty("source") | ||
public void setSource(String source) { | ||
this.source = source; | ||
} | ||
|
||
@JsonProperty("thumbnail") | ||
public String getThumbnail() { | ||
return thumbnail; | ||
} | ||
|
||
@JsonProperty("thumbnail") | ||
public void setThumbnail(String thumbnail) { | ||
this.thumbnail = thumbnail; | ||
} | ||
|
||
@JsonProperty("icon") | ||
public String getIcon() { | ||
return icon; | ||
} | ||
|
||
@JsonProperty("icon") | ||
public void setIcon(String icon) { | ||
this.icon = icon; | ||
} | ||
|
||
@JsonProperty("uid") | ||
public String getUid() { | ||
return uid; | ||
} | ||
|
||
@JsonProperty("uid") | ||
public void setUid(String uid) { | ||
this.uid = uid; | ||
} | ||
|
||
@JsonProperty("link") | ||
public String getLink() { | ||
return link; | ||
} | ||
|
||
@JsonProperty("link") | ||
public void setLink(String link) { | ||
this.link = link; | ||
} | ||
|
||
@JsonProperty("updatetime") | ||
public String getUpdatetime() { | ||
return updatetime; | ||
} | ||
|
||
@JsonProperty("updatetime") | ||
public void setUpdatetime(String updatetime) { | ||
this.updatetime = updatetime; | ||
} | ||
|
||
@JsonProperty("author") | ||
public String getAuthor() { | ||
return author; | ||
} | ||
|
||
@JsonProperty("author") | ||
public void setAuthor(String author) { | ||
this.author = author; | ||
} | ||
|
||
@JsonProperty("sourcetitle") | ||
public String getSourcetitle() { | ||
return sourcetitle; | ||
} | ||
|
||
@JsonProperty("sourcetitle") | ||
public void setSourcetitle(String sourcetitle) { | ||
this.sourcetitle = sourcetitle; | ||
} | ||
|
||
@JsonProperty("tags") | ||
public String getTags() { | ||
return tags; | ||
} | ||
|
||
@JsonProperty("tags") | ||
public void setTags(String tags) { | ||
this.tags = tags; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Article [datetime=" + datetime + ", title=" + title + ", author=" + author + "]"; | ||
} | ||
|
||
|
||
|
||
} |
29 changes: 29 additions & 0 deletions
29
src/test/java/de/sebwarnke/restwrapper/selfoss/SmokeTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.sebwarnke.restwrapper.selfoss; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import de.sebwarnke.restwrapper.selfoss.SelfossWrapper; | ||
import de.sebwarnke.restwrapper.selfoss.model.Article; | ||
|
||
public class SmokeTests { | ||
|
||
private Logger log = LoggerFactory.getLogger(SmokeTests.class); | ||
|
||
@Test | ||
public void testGetArticles() { | ||
|
||
SelfossWrapper selfossWrapper = new SelfossWrapper(); | ||
List<Article> articles = selfossWrapper.getArticles(); | ||
|
||
Assert.assertFalse(articles.isEmpty()); | ||
|
||
articles.forEach(article -> { | ||
log.debug(article.toString()); | ||
}); | ||
} | ||
} |