use of com.auth0.json.mgmt.logstreams.LogStream in project auth0-java by auth0.
the class LogStreamsEntityTest method shouldUpdateLogStream.
@Test
public void shouldUpdateLogStream() throws Exception {
LogStream logStream = getLogStream("log stream", null);
logStream.setStatus("paused");
Request<LogStream> request = api.logStreams().update("123", logStream);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_LOG_STREAM, 200);
LogStream response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("PATCH", "/api/v2/log-streams/123"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(3));
assertThat(body, hasEntry("name", "log stream"));
assertThat(body, hasEntry("status", "paused"));
assertThat(body, hasEntry("sink", logStream.getSink()));
assertThat(response, is(notNullValue()));
assertThat(response, hasProperty("id", is(notNullValue())));
assertThat(response, hasProperty("name", is(notNullValue())));
assertThat(response, hasProperty("type", is(notNullValue())));
assertThat(response, hasProperty("status", is(notNullValue())));
assertThat(response, hasProperty("sink", is(notNullValue())));
}
use of com.auth0.json.mgmt.logstreams.LogStream in project auth0-java by auth0.
the class LogStreamsEntityTest method getLogStream.
private LogStream getLogStream(String name, String type) {
LogStream logStream = new LogStream(type);
logStream.setName(name);
Map<String, Object> sink = new HashMap<>();
sink.put("httpEndpoint", "https://me.org");
sink.put("httpAuthorization", "abc123");
sink.put("httpContentFormat", "JSONLINES");
sink.put("httpContentType", "application/json");
logStream.setSink(sink);
return logStream;
}
use of com.auth0.json.mgmt.logstreams.LogStream in project auth0-java by auth0.
the class LogStreamsEntityTest method shouldThrowOnUpdateLogStreamWithNullId.
@Test
public void shouldThrowOnUpdateLogStreamWithNullId() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("'log stream id' cannot be null!");
api.logStreams().update(null, new LogStream());
}
use of com.auth0.json.mgmt.logstreams.LogStream in project auth0-java by auth0.
the class LogStreamsEntityTest method shouldGetLogStream.
@Test
public void shouldGetLogStream() throws Exception {
Request<LogStream> request = api.logStreams().get("123");
assertThat(request, is(notNullValue()));
server.jsonResponse(MockServer.MGMT_LOG_STREAM, 200);
LogStream response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/log-streams/123"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(response, is(notNullValue()));
assertThat(response, hasProperty("id", is(notNullValue())));
assertThat(response, hasProperty("name", is(notNullValue())));
assertThat(response, hasProperty("type", is(notNullValue())));
assertThat(response, hasProperty("status", is(notNullValue())));
assertThat(response, hasProperty("sink", is(notNullValue())));
}
use of com.auth0.json.mgmt.logstreams.LogStream in project auth0-java by auth0.
the class LogStreamsEntityTest method shouldCreateLogStream.
@Test
public void shouldCreateLogStream() throws Exception {
LogStream logStream = getLogStream("log stream", "http");
Request<LogStream> request = api.logStreams().create(logStream);
assertThat(request, is(notNullValue()));
server.jsonResponse(MGMT_LOG_STREAM, 200);
LogStream response = request.execute();
RecordedRequest recordedRequest = server.takeRequest();
assertThat(recordedRequest, hasMethodAndPath("POST", "/api/v2/log-streams"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
Map<String, Object> body = bodyFromRequest(recordedRequest);
assertThat(body.size(), is(3));
assertThat(body, hasEntry("name", "log stream"));
assertThat(body, hasEntry("type", "http"));
assertThat(body, hasEntry("sink", logStream.getSink()));
assertThat(response, is(notNullValue()));
assertThat(response, hasProperty("id", is(notNullValue())));
assertThat(response, hasProperty("name", is(notNullValue())));
assertThat(response, hasProperty("type", is(notNullValue())));
assertThat(response, hasProperty("status", is(notNullValue())));
assertThat(response, hasProperty("sink", is(notNullValue())));
}
Aggregations