use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.GetSourceOptions in project event-notifications-java-admin-sdk by IBM.
the class EventNotificationsTest method testGetSourceWOptions.
// Test the getSource operation with a valid options model parameter
@Test
public void testGetSourceWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"id\": \"id\", \"name\": \"name\", \"description\": \"description\", \"enabled\": false, \"type\": \"type\", \"updated_at\": \"2019-01-01T12:00:00.000Z\", \"topic_count\": 10, \"topic_names\": [\"topicNames\"]}";
String getSourcePath = "/v1/instances/testString/sources/testString";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
// Construct an instance of the GetSourceOptions model
GetSourceOptions getSourceOptionsModel = new GetSourceOptions.Builder().instanceId("testString").id("testString").build();
// Invoke getSource() with a valid options model and verify the result
Response<Source> response = eventNotificationsService.getSource(getSourceOptionsModel).execute();
assertNotNull(response);
Source 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(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getSourcePath);
// 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.GetSourceOptions in project event-notifications-java-admin-sdk by IBM.
the class GetSourceOptionsTest method testGetSourceOptions.
@Test
public void testGetSourceOptions() throws Throwable {
GetSourceOptions getSourceOptionsModel = new GetSourceOptions.Builder().instanceId("testString").id("testString").build();
assertEquals(getSourceOptionsModel.instanceId(), "testString");
assertEquals(getSourceOptionsModel.id(), "testString");
}
use of com.ibm.cloud.eventnotifications.event_notifications.v1.model.GetSourceOptions in project event-notifications-java-admin-sdk by IBM.
the class EventNotifications method getSource.
/**
* Get a Source.
*
* Get a Sources.
*
* @param getSourceOptions the {@link GetSourceOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link Source}
*/
public ServiceCall<Source> getSource(GetSourceOptions getSourceOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(getSourceOptions, "getSourceOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("instance_id", getSourceOptions.instanceId());
pathParamsMap.put("id", getSourceOptions.id());
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/instances/{instance_id}/sources/{id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("event_notifications", "v1", "getSource");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<Source> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<Source>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
Aggregations