-
Notifications
You must be signed in to change notification settings - Fork 142
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
366f046
commit f0c319d
Showing
3 changed files
with
41 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,10 @@ | |
*/ | ||
package com.jcabi.github; | ||
|
||
import com.jcabi.http.mock.MkAnswer; | ||
import com.jcabi.http.mock.MkContainer; | ||
import com.jcabi.http.mock.MkGrizzlyContainer; | ||
import com.jcabi.http.request.ApacheRequest; | ||
import com.jcabi.http.request.FakeRequest; | ||
import java.net.HttpURLConnection; | ||
import java.util.Collections; | ||
|
@@ -70,15 +74,24 @@ public void fetchesEmails() throws Exception { | |
@Test | ||
public void addsEmails() throws Exception { | ||
final String email = "[email protected]"; | ||
final UserEmails emails = new RtUserEmails( | ||
new FakeRequest() | ||
.withStatus(HttpURLConnection.HTTP_CREATED) | ||
.withBody(String.format("[{\"email\":\"%s\"}]", email)) | ||
); | ||
MatcherAssert.assertThat( | ||
emails.add(Collections.singletonList(email)).iterator().next(), | ||
Matchers.equalTo(email) | ||
final MkContainer container = new MkGrizzlyContainer().next( | ||
new MkAnswer.Simple( | ||
HttpURLConnection.HTTP_CREATED, | ||
String.format("[{\"email\":\"%s\"}]", email) | ||
) | ||
); | ||
container.start(); | ||
try { | ||
final UserEmails emails = new RtUserEmails( | ||
new ApacheRequest(container.home()) | ||
); | ||
MatcherAssert.assertThat( | ||
emails.add(Collections.singletonList(email)).iterator().next(), | ||
Matchers.equalTo(email) | ||
); | ||
} finally { | ||
container.stop(); | ||
} | ||
} | ||
|
||
/** | ||
|