This repository has been archived by the owner on Dec 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
9940c56
commit d950b3c
Showing
6 changed files
with
312 additions
and
28 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
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
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
95 changes: 95 additions & 0 deletions
95
src/test/java/com/amihaiemil/charles/rest/model/IssueCommentNotificationTestCase.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,95 @@ | ||
/** | ||
* Copyright (c) 2016-2017, Mihai Emil Andronache | ||
* All rights reserved. | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* 1)Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2)Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3)Neither the name of charles-rest nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.amihaiemil.charles.rest.model; | ||
|
||
import javax.json.Json; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Unit tests for {@link IssueCommentNotification} | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 1.0.2 | ||
* | ||
*/ | ||
public final class IssueCommentNotificationTestCase { | ||
|
||
/** | ||
* A IssueCommentNotification has an issue number. | ||
*/ | ||
@Test | ||
public void hasIssueNumber() { | ||
final Notification notification = new IssueCommentNotification( | ||
Json.createObjectBuilder() | ||
.add( | ||
"issue", | ||
Json.createObjectBuilder().add("number", 456).build() | ||
) | ||
.build() | ||
); | ||
MatcherAssert.assertThat(notification.issueNumber(), Matchers.is(456)); | ||
} | ||
|
||
/** | ||
* A IssueCommentNotification has a repository fullname. | ||
*/ | ||
@Test | ||
public void hasRepoFullName() { | ||
final Notification notification = new IssueCommentNotification( | ||
Json.createObjectBuilder() | ||
.add( | ||
"repository", | ||
Json.createObjectBuilder().add("full_name", "jeff/test").build() | ||
) | ||
.build() | ||
); | ||
MatcherAssert.assertThat(notification.repoFullName(), Matchers.equalTo("jeff/test")); | ||
} | ||
|
||
/** | ||
* A IssueCommentNotification has all its attributes. | ||
*/ | ||
@Test | ||
public void isComplete() { | ||
final Notification notification = new IssueCommentNotification( | ||
Json.createObjectBuilder() | ||
.add( | ||
"issue", | ||
Json.createObjectBuilder().add("number", 899).build() | ||
) | ||
.add( | ||
"repository", | ||
Json.createObjectBuilder().add("full_name", "jeff/test").build() | ||
) | ||
.build() | ||
); | ||
MatcherAssert.assertThat(notification.issueNumber(), Matchers.is(899)); | ||
MatcherAssert.assertThat(notification.repoFullName(), Matchers.equalTo("jeff/test")); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/test/java/com/amihaiemil/charles/rest/model/SimplifiedNotificationsTestCase.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,100 @@ | ||
/** | ||
* Copyright (c) 2016-2017, Mihai Emil Andronache | ||
* All rights reserved. | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* 1)Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2)Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3)Neither the name of charles-rest nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.amihaiemil.charles.rest.model; | ||
|
||
import javax.json.Json; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Unit tests for {@link SimplifiedNotifications} | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 1.0.2 | ||
* | ||
*/ | ||
@SuppressWarnings("unused") | ||
public final class SimplifiedNotificationsTestCase { | ||
|
||
|
||
/** | ||
* SimplifiedNotifications can iterate over all of them. | ||
*/ | ||
@Test | ||
public void iteratesOverAll() { | ||
final Notifications notifs = new SimplifiedNotifications( | ||
Json.createArrayBuilder() | ||
.add(Json.createObjectBuilder().add("repoFullName", "jeff/test").add("issueNumber", 123).build()) | ||
.add(Json.createObjectBuilder().add("repoFullName", "mary/tesla").add("issueNumber", 458).build()) | ||
.add(Json.createObjectBuilder().add("repoFullName", "john/doe-repo").add("issueNumber", 142).build()) | ||
.build() | ||
.toString() | ||
); | ||
int size = 0; | ||
for(final Notification n : notifs) { | ||
size++; | ||
} | ||
MatcherAssert.assertThat(size, Matchers.is(3)); | ||
} | ||
|
||
/** | ||
* SimplifiedNotifications can iterate over a single notification. | ||
*/ | ||
@Test | ||
public void iteratesOverOne() { | ||
final Notifications notifs = new SimplifiedNotifications( | ||
Json.createArrayBuilder() | ||
.add(Json.createObjectBuilder().add("repoFullName", "mary/tesla").add("issueNumber", 458).build()) | ||
.build() | ||
.toString() | ||
); | ||
int size = 0; | ||
for(final Notification n : notifs) { | ||
size++; | ||
} | ||
MatcherAssert.assertThat(size, Matchers.is(1)); | ||
} | ||
|
||
/** | ||
* SimplifiedNotifications can iterate over no notification (it is empty). | ||
*/ | ||
@Test | ||
public void iteratesOverNone() { | ||
final Notifications notifs = new SimplifiedNotifications( | ||
Json.createArrayBuilder() | ||
.build() | ||
.toString() | ||
); | ||
int size = 0; | ||
for(final Notification n : notifs) { | ||
size++; | ||
} | ||
MatcherAssert.assertThat(size, Matchers.is(0)); | ||
} | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
src/test/java/com/amihaiemil/charles/rest/model/WebhookNotificationsTestCase.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,89 @@ | ||
/** | ||
* Copyright (c) 2016-2017, Mihai Emil Andronache | ||
* All rights reserved. | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* 1)Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2)Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3)Neither the name of charles-rest nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.amihaiemil.charles.rest.model; | ||
|
||
import javax.json.Json; | ||
import javax.json.JsonObject; | ||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Unit tests for {@link WebhookNotifications} | ||
* @author Mihai Andronache ([email protected]) | ||
* @version $Id$ | ||
* @since 1.0.2 | ||
* | ||
*/ | ||
@SuppressWarnings("unused") | ||
public final class WebhookNotificationsTestCase { | ||
|
||
/** | ||
* WebhookNotifications can iterate over all of them. | ||
*/ | ||
@Test | ||
public void iteratesOverAll() { | ||
final Notifications notifs = new WebhookNotifications( | ||
Json.createObjectBuilder().build(), | ||
Json.createObjectBuilder().build(), | ||
Json.createObjectBuilder().build(), | ||
Json.createObjectBuilder().build() | ||
); | ||
int size = 0; | ||
for(final Notification n : notifs) { | ||
size++; | ||
} | ||
MatcherAssert.assertThat(size, Matchers.is(4)); | ||
} | ||
|
||
/** | ||
* WebhookNotifications can iterate over a single notification. | ||
*/ | ||
@Test | ||
public void iteratesOverOne() { | ||
final Notifications notifs = new WebhookNotifications( | ||
Json.createObjectBuilder().build() | ||
); | ||
int size = 0; | ||
for(final Notification n : notifs) { | ||
size++; | ||
} | ||
MatcherAssert.assertThat(size, Matchers.is(1)); | ||
} | ||
|
||
/** | ||
* WebhookNotifications can iterate over no notification (it is empty). | ||
*/ | ||
@Test | ||
public void iteratesOverNone() { | ||
final Notifications notifs = new WebhookNotifications(new JsonObject[]{}); | ||
int size = 0; | ||
for(final Notification n : notifs) { | ||
size++; | ||
} | ||
MatcherAssert.assertThat(size, Matchers.is(0)); | ||
} | ||
} |
d950b3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
150-f4a028a1
disappeared fromsrc/main/java/com/amihaiemil/charles/aws/AmazonEsRepository.java
, that's why I closed #157.d950b3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
150-d3633346
disappeared fromsrc/main/java/com/amihaiemil/charles/aws/AmazonEsSuggest.java
, that's why I closed #158.d950b3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
150-54535ee7
disappeared fromsrc/main/java/com/amihaiemil/charles/aws/SuggestQuery.java
, that's why I closed #159.d950b3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
150-47fee5a9
disappeared fromsrc/main/java/com/amihaiemil/charles/aws/SuggestionsResponseHandler.java
, that's why I closed #160.d950b3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
176-a617e601
disappeared fromsrc/main/java/com/amihaiemil/charles/github/Command.java
, that's why I closed #185.d950b3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
199-aff84e88
disappeared fromsrc/main/java/com/amihaiemil/charles/aws/SystemProperty.java
, that's why I closed #201.d950b3c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
250-d7d97575
disappeared fromsrc/main/java/com/amihaiemil/charles/aws/AmazonEsRepository.java
, that's why I closed #261.