-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
readside-impl/src/test/java/com/lightbend/readside/impl/N1qlDslTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.lightbend.readside.impl; | ||
|
||
import com.couchbase.client.java.document.json.JsonArray; | ||
import com.couchbase.client.java.query.dsl.path.UpdateSetPath; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import static com.couchbase.client.java.query.Update.update; | ||
import static com.couchbase.client.java.query.dsl.Expression.x; | ||
import static com.couchbase.client.java.query.dsl.functions.ArrayFunctions.arrayPrepend; | ||
import static com.couchbase.client.java.query.dsl.functions.ConditionalFunctions.ifNull; | ||
|
||
public class N1qlDslTests { | ||
|
||
@Test | ||
public void test() { | ||
|
||
UpdateSetPath updateSetPath = | ||
update("test") | ||
.useKeys("$1") | ||
.set("messages", arrayPrepend(ifNull(x("messages"), x(JsonArray.empty())), x("$2"))) | ||
.set("message", "$2"); | ||
|
||
|
||
Assert.assertEquals("UPDATE test USE KEYS $1 SET messages = ARRAY_PREPEND($2, IFNULL(messages, [])), message = $2;", updateSetPath.toString()); | ||
|
||
} | ||
} |