From d7650d7440671a191f787b06d79147a90b123e6b Mon Sep 17 00:00:00 2001 From: Angelo Paparazzi Date: Wed, 4 Dec 2024 14:55:37 -0600 Subject: [PATCH] chore: java 8 compatibility --- assistant/pom.xml | 12 ------- .../v2/model/MessageEventDeserializer.java | 12 +++---- .../assistant/v2/AssistantServiceIT.java | 34 +++++++++---------- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/assistant/pom.xml b/assistant/pom.xml index d3630854ce..5450d34449 100644 --- a/assistant/pom.xml +++ b/assistant/pom.xml @@ -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"> 4.0.0 - - - - org.apache.maven.plugins - maven-compiler-plugin - - 11 - 11 - - - - ibm-watson-parent diff --git a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageEventDeserializer.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageEventDeserializer.java index 3c02ccda36..48c0fd7777 100644 --- a/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageEventDeserializer.java +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageEventDeserializer.java @@ -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(); } @@ -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; @@ -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; } @@ -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; } diff --git a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java index dcc7118f37..6984d962f9 100644 --- a/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java @@ -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); @@ -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); } @@ -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") @@ -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());