use of com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testStartAConversationWithoutMessage.
/**
* Test start a conversation without message.
*/
@Test()
public void testStartAConversationWithoutMessage() {
MessageOptions options = new MessageOptions.Builder(workspaceId).build();
service.message(options).execute();
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testExample.
/**
* Test Example.
*/
@Test
public void testExample() {
// Conversation service = new Conversation(Conversation.VERSION_DATE_2017_05_26);
// service.setUsernameAndPassword("<username>", "<password>");
InputData input = new InputData.Builder("Hi").build();
MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build();
// sync
MessageResponse response = service.message(options).execute();
System.out.println(response);
// async
service.message(options).enqueue(new ServiceCallback<MessageResponse>() {
@Override
public void onResponse(MessageResponse response) {
System.out.println(response);
}
@Override
public void onFailure(Exception e) {
}
});
// rx callback
service.message(options).rx().thenApply(new CompletableFuture.Fun<MessageResponse, OutputData>() {
@Override
public OutputData apply(MessageResponse message) {
return message.getOutput();
}
}).thenAccept(new CompletableFuture.Action<OutputData>() {
@Override
public void accept(OutputData output) {
System.out.println(output);
}
});
// rx async callback
service.message(options).rx().thenApplyAsync(new CompletableFuture.Fun<MessageResponse, OutputData>() {
@Override
public OutputData apply(MessageResponse message) {
return message.getOutput();
}
}).thenAccept(new CompletableFuture.Action<OutputData>() {
@Override
public void accept(OutputData output) {
System.out.println(output);
}
});
// rx sync
try {
MessageResponse rxMessageResponse = service.message(options).rx().get();
System.out.println(rxMessageResponse);
} catch (Exception ex) {
// Handle exception
}
}
use of com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions in project java-sdk by watson-developer-cloud.
the class ConversationServiceIT method testReadme.
/**
* Test README.
*/
@Test
public void testReadme() {
// Conversation service = new Conversation(Conversation.VERSION_DATE_2017_05_26);
// service.setUsernameAndPassword("<username>", "<password>");
InputData input = new InputData.Builder("Hi").build();
MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build();
MessageResponse response = service.message(options).execute();
System.out.println(response);
}
Aggregations