Skip to content

Commit

Permalink
chore: java 8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
apaparazzi0329 committed Dec 5, 2024
1 parent 1c427f5 commit 1a35099
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
12 changes: 0 additions & 12 deletions assistant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

<parent>
<artifactId>ibm-watson-parent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Builder() {}
* @param inputStream the inputStream
*/
public Builder(InputStream inputStream) {
var inputStreamConnectStrategy =
InputStreamConnectStrategy inputStreamConnectStrategy =
new InputStreamConnectStrategy.Builder().inputStream(inputStream).build();
this.eventSource = new EventSource.Builder(inputStreamConnectStrategy).build();
}
Expand All @@ -66,7 +66,7 @@ public MessageEventDeserializer build() {
* @return the MessageEventDeserializer builder
*/
public MessageEventDeserializer.Builder inputStream(InputStream inputStream) {
var inputStreamConnectStrategy =
InputStreamConnectStrategy inputStreamConnectStrategy =
new InputStreamConnectStrategy.Builder().inputStream(inputStream).build();
this.eventSource = new EventSource.Builder(inputStreamConnectStrategy).build();
return this;
Expand Down Expand Up @@ -109,8 +109,8 @@ public boolean hasNext() {
}

public T next() {
var gson = new Gson();
var messageEvent = messageEvents.iterator().next();
Gson gson = new Gson();
MessageEvent messageEvent = messageEvents.iterator().next();
T item = (T) gson.fromJson(messageEvent.getData(), MessageStreamResponse.class);
return item;
}
Expand All @@ -128,8 +128,8 @@ public boolean hasNext() {
}

public T next() {
var gson = new Gson();
var messageEvent = messageEvents.iterator().next();
Gson gson = new Gson();
MessageEvent messageEvent = messageEvents.iterator().next();
T item = (T) gson.fromJson(messageEvent.getData(), StatelessMessageStreamResponse.class);
return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ public void testGettingReleases() {
/** Test Provider API */
@Test
public void testProviders() {
var listProviderOptions = new ListProvidersOptions.Builder().build();
var listProvidersResponse = service.listProviders(listProviderOptions).execute().getResult();
var providerId = listProvidersResponse.getConversationalSkillProviders().get(0).getProviderId();
ListProvidersOptions listProviderOptions = new ListProvidersOptions.Builder().build();
ProviderCollection listProvidersResponse = service.listProviders(listProviderOptions).execute().getResult();
String providerId = listProvidersResponse.getConversationalSkillProviders().get(0).getProviderId();
assertNotNull(listProvidersResponse);
assertNotNull(providerId);

Expand All @@ -311,19 +311,19 @@ public void testProviders() {
ProviderSpecification providerSpecification =
new ProviderSpecification.Builder().servers(serverList).build();

var password = new ProviderAuthenticationTypeAndValue.Builder().type("value").value("test").build();
var basicFlow = new ProviderPrivateAuthenticationBasicFlow.Builder().password(password).build();
var providerPrivate = new ProviderPrivate.Builder().authentication(basicFlow).build();
ProviderAuthenticationTypeAndValue password = new ProviderAuthenticationTypeAndValue.Builder().type("value").value("test").build();
ProviderPrivateAuthenticationBasicFlow basicFlow = new ProviderPrivateAuthenticationBasicFlow.Builder().password(password).build();
ProviderPrivate providerPrivate = new ProviderPrivate.Builder().authentication(basicFlow).build();

// service.setServiceUrl("http://localhost:9001");

var updateProvidersOptions =
UpdateProviderOptions updateProvidersOptions =
new UpdateProviderOptions.Builder()
.providerId(providerId)
.specification(providerSpecification)
.xPrivate(providerPrivate)
.build();
var updateProvidersResponse =
ProviderResponse updateProvidersResponse =
service.updateProvider(updateProvidersOptions).execute().getResult();
assertNotNull(updateProvidersResponse);
}
Expand All @@ -332,37 +332,37 @@ public void testProviders() {
@Test
public void testImportRelease() throws IOException {
InputStream testFile = new FileInputStream(RESOURCE + "demo_wa_V4.zip");
var importOptions =
CreateReleaseImportOptions importOptions =
new CreateReleaseImportOptions.Builder().assistantId(assistantId).body(testFile).build();
var importResponse = service.createReleaseImport(importOptions).execute().getResult();
CreateAssistantReleaseImportResponse importResponse = service.createReleaseImport(importOptions).execute().getResult();
assertNotNull(importResponse);
}

@Test
public void testDownloadExportRelease() throws IOException {
var exportOptions =
DownloadReleaseExportOptions exportOptions =
new DownloadReleaseExportOptions.Builder().assistantId(assistantId).release("1").build();
var exportResponse = service.downloadReleaseExport(exportOptions).execute().getResult();
CreateReleaseExportWithStatusErrors exportResponse = service.downloadReleaseExport(exportOptions).execute().getResult();
assertNotNull(exportResponse);
}

@Test
public void testDownloadExportReleaseStream() throws IOException {
var exportOptions =
DownloadReleaseExportOptions exportOptions =
new DownloadReleaseExportOptions.Builder().assistantId(assistantId).release("1").build();
var exportReleaseStream =
InputStream exportReleaseStream =
service.downloadReleaseExportAsStream(exportOptions).execute().getResult();
assertNotNull(exportReleaseStream);
}

@Test
public void testMessageStreamStateless() throws IOException, StreamException {
var messageInput =
MessageInput messageInput =
new MessageInput.Builder()
.messageType("text")
.text("can you list the steps to create a custom extension?")
.build();
var messageStreamStatelessOptions =
MessageStreamStatelessOptions messageStreamStatelessOptions =
new MessageStreamStatelessOptions.Builder()
.assistantId("99a74576-47de-42a9-ab05-9dd98978809b")
.environmentId("03dce212-1aa3-436a-a747-8717a96ded5a")
Expand All @@ -372,7 +372,7 @@ public void testMessageStreamStateless() throws IOException, StreamException {
InputStream inputStream =
service.messageStreamStateless(messageStreamStatelessOptions).execute().getResult();

var messageDeserializer = new MessageEventDeserializer.Builder(inputStream).build();
MessageEventDeserializer messageDeserializer = new MessageEventDeserializer.Builder(inputStream).build();
for (StatelessMessageStreamResponse message : messageDeserializer.statelessMessages()) {
if (message.getPartialItem() != null) {
assertNotNull(message.getPartialItem().getText());
Expand Down

0 comments on commit 1a35099

Please sign in to comment.