refactor: update CSV response handling to return true for empty or null responses
This commit is contained in:
@@ -3,8 +3,8 @@ package de.extio.lmlib.agent.responsehandler;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -62,7 +62,7 @@ public class CsvAgentResponseHandler implements StreamedAgentResponseHandler {
|
|||||||
final String resp = completion.response();
|
final String resp = completion.response();
|
||||||
if (resp == null || resp.isBlank()) {
|
if (resp == null || resp.isBlank()) {
|
||||||
LOGGER.warn("Empty completion response for CSV parsing");
|
LOGGER.warn("Empty completion response for CSV parsing");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class CsvUnmarshallingAgentResponseHandler implements AgentResponseHandle
|
|||||||
final String resp = completion.response();
|
final String resp = completion.response();
|
||||||
if (resp == null || resp.isBlank()) {
|
if (resp == null || resp.isBlank()) {
|
||||||
LOGGER.warn("Empty completion response for CSV parsing");
|
LOGGER.warn("Empty completion response for CSV parsing");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -235,7 +235,9 @@ public class CsvAgentResponseHandlerTest {
|
|||||||
final Completion completion = new Completion("", null, null, null);
|
final Completion completion = new Completion("", null, null, null);
|
||||||
final boolean result = handler.handle(completion, context);
|
final boolean result = handler.handle(completion, context);
|
||||||
|
|
||||||
assertFalse(result);
|
assertTrue(result);
|
||||||
|
assertTrue(context.getStringValues("empty_a") == null || context.getStringValues("empty_a").isEmpty());
|
||||||
|
assertTrue(context.getStringValues("empty_b") == null || context.getStringValues("empty_b").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -247,7 +249,9 @@ public class CsvAgentResponseHandlerTest {
|
|||||||
final Completion completion = new Completion(null, null, null, null);
|
final Completion completion = new Completion(null, null, null, null);
|
||||||
final boolean result = handler.handle(completion, context);
|
final boolean result = handler.handle(completion, context);
|
||||||
|
|
||||||
assertFalse(result);
|
assertTrue(result);
|
||||||
|
assertTrue(context.getStringValues("null_a") == null || context.getStringValues("null_a").isEmpty());
|
||||||
|
assertTrue(context.getStringValues("null_b") == null || context.getStringValues("null_b").isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user