Skip to content

Commit

Permalink
Making test method names more helpful, adding tests for deleting streams
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisoelkers committed Jun 25, 2015
1 parent 1491a9e commit 2a6c7f5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
Expand Up @@ -110,7 +110,7 @@ public void createStreamWithTitleAndDescription() throws Exception {
} }


@Test @Test
public void incompleteStream() throws Exception { public void creatingIncompleteStreamShouldFail() throws Exception {
final int beforeCount = streamCount(); final int beforeCount = streamCount();


final ValidatableResponse response = createStreamFromRequest(jsonResourceForMethod()); final ValidatableResponse response = createStreamFromRequest(jsonResourceForMethod());
Expand All @@ -121,7 +121,8 @@ public void incompleteStream() throws Exception {
} }


@Test @Test
public void invalidStream() throws Exception { @MongoDbSeed
public void creatingInvalidStreamShouldFail() throws Exception {
final int beforeCount = streamCount(); final int beforeCount = streamCount();


final ValidatableResponse response = createStreamFromRequest("{}"); final ValidatableResponse response = createStreamFromRequest("{}");
Expand All @@ -131,6 +132,42 @@ public void invalidStream() throws Exception {
assertThat(afterCount).isEqualTo(beforeCount); assertThat(afterCount).isEqualTo(beforeCount);
} }


@Test
@MongoDbSeed(locations = {"single-stream"})
public void deletingSingleStream() {
final String streamId = "552b92b2e4b0c055e41ffb8e";
assertThat(streamCount()).isEqualTo(1);

given()
.when()
.delete("/streams/"+streamId)
.then()
.statusCode(204);

assertThat(streamCount()).isEqualTo(0);

given()
.when()
.get("/streams/"+streamId)
.then()
.statusCode(404);
}

@Test
@MongoDbSeed(locations = {"single-stream"})
public void deletingNonexistentStreamShouldFail() {
final String streamId = "552b92b2e4b0c055e41ffb8f";
assertThat(streamCount()).isEqualTo(1);

given()
.when()
.delete("/streams/"+streamId)
.then()
.statusCode(404);

assertThat(streamCount()).isEqualTo(1);
}

protected ValidatableResponse createStreamFromRequest(byte[] request) { protected ValidatableResponse createStreamFromRequest(byte[] request) {
return given() return given()
.when() .when()
Expand Down

0 comments on commit 2a6c7f5

Please sign in to comment.