Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ public Builder withScriptName(String scriptName) {

public UpdateQuery build() {

if (script == null && document == null && query == null) {
throw new IllegalArgumentException("either script, document or query must be set");
if (script == null && scriptName == null && document == null && query == null) {
throw new IllegalArgumentException("either script, scriptName, document or query must be set");
}

return new UpdateQuery(id, script, params, document, upsert, lang, routing, scriptedUpsert, docAsUpsert,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.springframework.data.elasticsearch.core.query;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.data.elasticsearch.core.document.Document;

class UpdateQueryTest {

@Test // #3205
@DisplayName("should build query with only a script")
void shouldBuildQueryWithOnlyAScript() {

UpdateQuery.builder("id")
.withScript("script")
.build();
}

@Test // #3205
@DisplayName("should build query with only a scriptname")
void shouldBuildQueryWithOnlyAScriptName() {

UpdateQuery.builder("id")
.withScriptName("scriptname")
.build();
}

@Test // #3205
@DisplayName("should build query with only a document")
void shouldBuildQueryWithOnlyASDocument() {

UpdateQuery.builder("id")
.withDocument(Document.create())
.build();
}

@Test // #3205
@DisplayName("should build query with only a query")
void shouldBuildQueryWithOnlyAQuery() {

Query query = StringQuery.builder("StrignQuery").build();

UpdateQuery.builder(query)
.build();
}
}
Loading