Skip to content
Permalink
Browse files

Patch release for the Java library 1.0.2

- Fixes pom.xml to package the bindings dependencies differently.
- Fixes issues with helper intents requiring simple response

Fixes: #4
Change-Id: I47b0899f9c0a8dd31d819bfb15d82f7c811628af
  • Loading branch information...
kishores committed Jan 23, 2019
1 parent f25eed0 commit f349b0e48cd0bf61ce960f2a08ba1ab6200d87e3
@@ -29,7 +29,7 @@ repositories {
}
dependencies {
compile group: 'com.google.actions', name: 'actions-on-google', version: '1.0.0
compile group: 'com.google.actions', name: 'actions-on-google', version: '1.0.2
}
```

@@ -40,8 +40,7 @@ If using maven, add the following to your pom.xml file.
<dependency>
<groupId>com.google.actions</groupId>
<artifactId>actions-on-google</artifactId>
<version>1.0.0</version>
<type>pom</type>
<version>1.0.2</version>
</dependency>
```

69 pom.xml
@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.actions</groupId>
<artifactId>actions-on-google</artifactId>
<version>1.0.0</version>
<version>1.0.2</version>
<packaging>jar</packaging>
<name>actions-on-google-java</name>
<url>http://actions.google.com</url>
@@ -57,6 +57,13 @@
<dokka.version>0.9.17</dokka.version>
</properties>

<repositories>
<repository>
<id>local-repo</id>
<url>file://${project.basedir}/local-repo</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>jcenter</id>
@@ -72,20 +79,16 @@
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.google.actions.v2</groupId>
<artifactId>google-actions-bindings</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/libactions_java_lib.jar
</systemPath>
<groupId>com.google.actions</groupId>
<artifactId>actions-bindings</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dialogflow.bindings</groupId>
<groupId>com.google.actions</groupId>
<artifactId>dialogflow-bindings</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/libdialogflow_java_lib.jar
</systemPath>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
@@ -161,6 +164,44 @@
</testSourceDirectory>

<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-actions-bindings</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>com.google.actions</groupId>
<artifactId>actions-bindings</artifactId>
<packaging>jar</packaging>
<version>2.0.0</version>
<file>${basedir}/lib/libactions_java_lib.jar</file>
<localRepositoryPath>${basedir}/local-repo</localRepositoryPath>
</configuration>
</execution>
<execution>
<id>install-dialogflow-bindings</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<file>${basedir}/lib/libdialogflow_java_lib.jar</file>
<groupId>com.google.actions</groupId>
<packaging>jar</packaging>
<artifactId>dialogflow-bindings</artifactId>
<version>2.0.0</version>
<localRepositoryPath>${basedir}/local-repo</localRepositoryPath>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
@@ -211,14 +252,14 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -235,7 +276,7 @@
<version>${dokka.version}</version>
<executions>
<execution>
<phase>pre-site</phase>
<phase>package</phase>
<goals>
<goal>dokka</goal>
</goals>
@@ -48,15 +48,19 @@ internal class AogResponse internal constructor(
if (appResponse == null) {
// If appResponse is provided, that supersedes all other values.
if (richResponse == null) {
richResponse = RichResponse()
if (responseBuilder.responseItems.size > 0) {
richResponse?.items = responseBuilder.responseItems
}
if (responseBuilder.suggestions.size > 0) {
richResponse?.suggestions = responseBuilder.suggestions
}
if (responseBuilder.linkOutSuggestion != null) {
richResponse?.linkOutSuggestion = responseBuilder.linkOutSuggestion
if (responseBuilder.responseItems.size > 0
|| responseBuilder.suggestions.size > 0
|| responseBuilder.linkOutSuggestion != null) {
richResponse = RichResponse()
if (responseBuilder.responseItems.size > 0) {
richResponse?.items = responseBuilder.responseItems
}
if (responseBuilder.suggestions.size > 0) {
richResponse?.suggestions = responseBuilder.suggestions
}
if (responseBuilder.linkOutSuggestion != null) {
richResponse?.linkOutSuggestion = responseBuilder.linkOutSuggestion
}
}
}
}
@@ -98,7 +102,7 @@ internal class AogResponse internal constructor(
if (richResponse != null) {
finalResponse.richResponse = richResponse
} else {
if (richResponse!!.items != null || richResponse!!.suggestions != null) {
if (richResponse?.items != null || richResponse?.suggestions != null) {
finalResponse.richResponse = richResponse
}
}
@@ -53,14 +53,7 @@ internal class ResponseSerializer(
}

val HELPER_INTENTS_REQUIRING_SIMPLE_RESPONSE = listOf(
"actions.intent.COMPLETE_PURCHASE",
"actions.intent.CONFIRMATION",
"actions.intent.DATETIME",
"actions.intent.PLACE",
"actions.intent.PERMISSION",
"actions.intent.NEW_SURFACE",
"actions.intent.OPTION",
"actions.intent.SIGN_IN"
"actions.intent.OPTION"
)
}

@@ -50,7 +50,6 @@ class AogResponseTest {
val responseBuilder = ResponseBuilder(usesDialogflow = false)
val confirmation = Confirmation().setConfirmationText("Are you sure?")
val jsonOutput = responseBuilder
.add("placeholder text")
.add(confirmation)
.build()
.toJson()
@@ -67,19 +66,6 @@ class AogResponseTest {
dialogSpec.get("requestConfirmationText").asString)
}

@Test
fun testAskConfirmationWithoutSimpleResponse() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)
val confirmation = Confirmation().setConfirmationText("Are you sure?")

assertThrows<Exception> {
responseBuilder
.add(confirmation)
.build()
.toJson()
}
}

@Test
fun testAskDateTime() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)
@@ -89,7 +75,6 @@ class AogResponseTest {
.setTimePrompt("What time?")

val jsonOutput = responseBuilder
.add("placeholder")
.add(dateTimePrompt)
.build()
.toJson()
@@ -110,27 +95,10 @@ class AogResponseTest {
dialogSpec.get("requestDatetimeText").asString)
}

@Test
fun testAskDateTimeWithoutSimpleResponse() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)
val dateTimePrompt = DateTimePrompt()
.setDatePrompt("What date?")
.setDateTimePrompt("What date and time?")
.setTimePrompt("What time?")

assertThrows<Exception> {
responseBuilder
.add(dateTimePrompt)
.build()
.toJson()
}
}

@Test
fun testAskPermission() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)
responseBuilder
.add("placeholder")
.add(Permission()
.setPermissions(arrayOf(PERMISSION_NAME,
PERMISSION_DEVICE_PRECISE_LOCATION))
@@ -153,27 +121,13 @@ class AogResponseTest {
.get(0).asString)
}

@Test
fun testAskPermissionWithoutSimpleResponse() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)
responseBuilder.add(Permission()
.setPermissions(arrayOf(PERMISSION_NAME,
PERMISSION_DEVICE_PRECISE_LOCATION))
.setContext("To get your name"))
val response = responseBuilder.build()
assertThrows<Exception> {
response.toJson()
}
}

@Test
fun testAskPlace() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)

val requestPrompt = "Where do you want to have lunch?"
val permissionPrompt = "To find lunch locations"
responseBuilder
.add("placeholder")
.add(Place()
.setRequestPrompt(requestPrompt)
.setPermissionContext(permissionPrompt))
@@ -198,29 +152,12 @@ class AogResponseTest {

}

@Test
fun testAskPlaceWithoutSimpleResponse() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)

val requestPrompt = "Where do you want to have lunch?"
val permissionPrompt = "To find lunch locations"
responseBuilder
.add(Place()
.setRequestPrompt(requestPrompt)
.setPermissionContext(permissionPrompt))
val response = responseBuilder.build()
assertThrows<Exception> {
response.toJson()
}
}

@Test
fun testAskSignIn() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)

responseBuilder.add(SignIn())
val response = responseBuilder
.add("placeholder")
.build()
val jsonOutput = response.toJson()

@@ -233,26 +170,13 @@ class AogResponseTest {
assertNotNull(inputValueData)
}

@Test
fun testAskSignInWithoutSimpleResponse() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)

responseBuilder.add(SignIn())
val response = responseBuilder
.build()
assertThrows<Exception> {
response.toJson()
}
}

@Test
fun testAskSignInWithContext() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)

responseBuilder.add(SignIn()
.setContext("For testing purposes"))
val response = responseBuilder
.add("placeholder")
.build()
val jsonOutput = response.toJson()

@@ -440,7 +364,6 @@ class AogResponseTest {
@Test
fun testAddSuggestions() {
val responseBuilder = ResponseBuilder(usesDialogflow = false)

responseBuilder
.add("this is a test")
.addSuggestions(arrayOf("one", "two", "three"))
@@ -459,7 +382,6 @@ class AogResponseTest {

@Test
fun testCompletePurchase() {
println("testCompletePurchase")
val responseBuilder = ResponseBuilder(usesDialogflow = false)

responseBuilder

0 comments on commit f349b0e

Please sign in to comment.
You can’t perform that action at this time.