use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.SourceResponse in project event-notifications-java-admin-sdk by IBM.
the class EventNotificationsTest method testCreateSourcesWOptions.
// Test the createSources operation with a valid options model parameter
@Test
public void testCreateSourcesWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"id\": \"id\", \"name\": \"name\", \"description\": \"description\", \"enabled\": false, \"created_at\": \"2019-01-01T12:00:00.000Z\"}";
String createSourcesPath = "/v1/instances/testString/sources";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(201).setBody(mockResponseBody));
// Construct an instance of the CreateSourcesOptions model
CreateSourcesOptions createSourcesOptionsModel = new CreateSourcesOptions.Builder().instanceId("testString").name("testString").description("testString").enabled(true).build();
// Invoke createSources() with a valid options model and verify the result
Response<SourceResponse> response = eventNotificationsService.createSources(createSourcesOptionsModel).execute();
assertNotNull(response);
SourceResponse responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, createSourcesPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.SourceResponse in project event-notifications-java-admin-sdk by IBM.
the class EventNotifications method createSources.
/**
* Create a new API Source.
*
* Create a new API Source.
*
* @param createSourcesOptions the {@link CreateSourcesOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SourceResponse}
*/
public ServiceCall<SourceResponse> createSources(CreateSourcesOptions createSourcesOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(createSourcesOptions, "createSourcesOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("instance_id", createSourcesOptions.instanceId());
RequestBuilder builder = RequestBuilder.post(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/instances/{instance_id}/sources", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("event_notifications", "v1", "createSources");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createSourcesOptions.name());
contentJson.addProperty("description", createSourcesOptions.description());
if (createSourcesOptions.enabled() != null) {
contentJson.addProperty("enabled", createSourcesOptions.enabled());
}
builder.bodyJson(contentJson);
ResponseConverter<SourceResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SourceResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.SourceResponse in project event-notifications-java-admin-sdk by IBM.
the class SourceResponseTest method testSourceResponse.
@Test
public void testSourceResponse() throws Throwable {
SourceResponse sourceResponseModel = new SourceResponse();
assertNull(sourceResponseModel.getId());
assertNull(sourceResponseModel.getName());
assertNull(sourceResponseModel.getDescription());
assertNull(sourceResponseModel.isEnabled());
assertNull(sourceResponseModel.getCreatedAt());
}
Aggregations