[Bug Fix] : Mongo Form Find - Projection field is parsed correctly (#4976)
* Parsing the field projection in Mongo Form * Added test case to assert Projection field working.
This commit is contained in:
parent
5b7add87db
commit
1bb54b0c7c
|
|
@ -89,7 +89,7 @@ public class Find extends MongoCommand {
|
|||
}
|
||||
|
||||
if (!StringUtils.isNullOrEmpty(this.projection)) {
|
||||
document.put("projection", this.projection);
|
||||
document.put("projection", parseSafely("Projection", this.projection));
|
||||
}
|
||||
|
||||
// Default to returning 10 documents if not mentioned
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import static com.external.plugins.constants.ConfigurationIndex.DELETE_LIMIT;
|
|||
import static com.external.plugins.constants.ConfigurationIndex.DELETE_QUERY;
|
||||
import static com.external.plugins.constants.ConfigurationIndex.DISTINCT_KEY;
|
||||
import static com.external.plugins.constants.ConfigurationIndex.DISTINCT_QUERY;
|
||||
import static com.external.plugins.constants.ConfigurationIndex.FIND_PROJECTION;
|
||||
import static com.external.plugins.constants.ConfigurationIndex.FIND_QUERY;
|
||||
import static com.external.plugins.constants.ConfigurationIndex.FIND_SORT;
|
||||
import static com.external.plugins.constants.ConfigurationIndex.INPUT_TYPE;
|
||||
|
|
@ -1304,4 +1305,36 @@ public class MongoPluginTest {
|
|||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindCommandProjection() {
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
|
||||
Map<Integer, Object> configMap = new HashMap<>();
|
||||
configMap.put(BSON, Boolean.FALSE);
|
||||
configMap.put(INPUT_TYPE, "FORM");
|
||||
configMap.put(COMMAND, "FIND");
|
||||
configMap.put(FIND_QUERY, "{ age: { \"$gte\": 30 } }");
|
||||
configMap.put(FIND_SORT, "{ id: 1 }");
|
||||
configMap.put(FIND_PROJECTION, "{ name: 1 }");
|
||||
configMap.put(COLLECTION, "users");
|
||||
|
||||
actionConfiguration.setPluginSpecifiedTemplates(generateMongoFormConfigTemplates(configMap));
|
||||
|
||||
DatasourceConfiguration dsConfig = createDatasourceConfiguration();
|
||||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn, new ExecuteActionDTO(), dsConfig, actionConfiguration));
|
||||
StepVerifier.create(executeMono)
|
||||
.assertNext(obj -> {
|
||||
System.out.println(obj);
|
||||
ActionExecutionResult result = (ActionExecutionResult) obj;
|
||||
assertNotNull(result);
|
||||
assertTrue(result.getIsExecutionSuccess());
|
||||
assertNotNull(result.getBody());
|
||||
assertEquals(2, ((ArrayNode) result.getBody()).size());
|
||||
JsonNode value = ((ArrayNode) result.getBody()).get(0).get("name");
|
||||
assertNotNull(value);
|
||||
})
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user