Merge remote-tracking branch 'origin/release' into fix-10771_text_widget_warning
This commit is contained in:
commit
5ebdb9dcff
|
|
@ -17,7 +17,10 @@
|
|||
"**/Smoke_TestSuite/ClientSideTests/DisplayWidgets/Table_Filter_spec*.js",
|
||||
"**/Smoke_TestSuite/ClientSideTests/Onboarding/FirstTimeUserOnboarding_spec*.js",
|
||||
"**/Smoke_TestSuite/ClientSideTests/LayoutValidation/AppPageLayout.spec.js",
|
||||
"**/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_spec.js"
|
||||
"**/Smoke_TestSuite/ClientSideTests/Templates/Fork_Template_spec.js",
|
||||
"**/Smoke_TestSuite/ClientSideTests/GenerateCRUD/MySQL_Spec.js",
|
||||
"**/Smoke_TestSuite/ServerSideTests/Datasources/MySQL_spec.js",
|
||||
"**/Smoke_TestSuite/ServerSideTests/Datasources/MySQLNoiseTest_spec.js"
|
||||
],
|
||||
"chromeWebSecurity": false,
|
||||
"viewportHeight": 1100,
|
||||
|
|
|
|||
|
|
@ -214,7 +214,9 @@ describe("Validate CRUD queries for Postgres along with UI flow verifications",
|
|||
.click();
|
||||
cy.wait(5000);
|
||||
|
||||
cy.xpath(generatePage.sortByDropdown).click(); //Sorting by descending to verify newly added record - also sorting is verified
|
||||
cy.get(generatePage.sortByDropdown)
|
||||
.last()
|
||||
.click(); //Sorting by descending to verify newly added record - also sorting is verified
|
||||
cy.xpath(generatePage.descending).click();
|
||||
cy.wait(2000); //for descending to take effect!
|
||||
cy.xpath(generatePage.currentNameField).should("have.value", "CRUD User31"); //Verifying Addition is success
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
"genderField": "//input[@placeholder='gender']",
|
||||
"emailField": "//input[@placeholder='email']",
|
||||
"submitBtn": "span:contains('Submit')",
|
||||
"sortByDropdown": "//div[@type='CANVAS_WIDGET']/div[contains(@class, 't--widget-dropdownwidget')][2]",
|
||||
"sortByDropdown": "span[name='dropdown']",
|
||||
"ascending": "//div[text()='Ascending']",
|
||||
"descending": "//div[text()='Descending']",
|
||||
"currentNameField": "//div[@type='FORM_WIDGET']//span[text()='name:']//ancestor::div[contains(@class,'t--widget-textwidget')]/following-sibling::div[contains(@class, 't--widget-inputwidgetv2')][1]//input",
|
||||
|
|
|
|||
|
|
@ -207,7 +207,9 @@ function* handleQueryCreatedSaga(actionPayload: ReduxAction<QueryAction>) {
|
|||
const queryTemplate = pluginTemplates[pluginId];
|
||||
// Do not show template view if the query has body(code) or if there are no templates
|
||||
const showTemplate = !(
|
||||
!!actionConfiguration.body || isEmpty(queryTemplate)
|
||||
!!actionConfiguration.body ||
|
||||
!!actionConfiguration.formData?.body ||
|
||||
isEmpty(queryTemplate)
|
||||
);
|
||||
history.replace(
|
||||
QUERIES_EDITOR_ID_URL(applicationId, pageId, id, {
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ public class DatasourceStructure {
|
|||
String title;
|
||||
String body;
|
||||
Object configuration;
|
||||
ActionConfiguration actionConfiguration;
|
||||
|
||||
// To create templates for plugins which store the configurations
|
||||
// in List<Property> format
|
||||
|
|
@ -131,20 +130,13 @@ public class DatasourceStructure {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create templates by passing UQI framework config and ActionConfiguration Object.
|
||||
*
|
||||
* For integrations that use UQI interface, a config map is used to indicate the required template. However,
|
||||
* some properties like `actionConfiguration.path` cannot be configured via the config map since the config
|
||||
* map only models the formData attribute. Such properties are configured via ActionConfiguration object.
|
||||
*
|
||||
* This seemed like a good choice over only using the ActionConfiguration object and skipping out on the
|
||||
* UQI/formData configuration map - as it would allow the Client application to re-use the UQI related
|
||||
* template code and augment the remaining fields with ActionConfiguration object.
|
||||
* Create templates by passing UQI framework config.
|
||||
* <p>
|
||||
* For integrations that use UQI interface, a config map is used to indicate the required template.
|
||||
*/
|
||||
public Template(String title, Map<String, ?> configuration, ActionConfiguration actionConfiguration) {
|
||||
public Template(String title, Map<String, ?> configuration) {
|
||||
this.title = title;
|
||||
this.configuration = configuration;
|
||||
this.actionConfiguration = actionConfiguration;
|
||||
}
|
||||
|
||||
// Creating templates without configuration
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.external.utils;
|
||||
|
||||
import com.appsmith.external.models.ActionConfiguration;
|
||||
import com.appsmith.external.models.DatasourceStructure.Template;
|
||||
import com.external.plugins.constants.AmazonS3Action;
|
||||
|
||||
|
|
@ -13,6 +12,7 @@ import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData
|
|||
import static com.external.plugins.AmazonS3Plugin.DEFAULT_URL_EXPIRY_IN_MINUTES;
|
||||
import static com.external.plugins.AmazonS3Plugin.NO;
|
||||
import static com.external.plugins.AmazonS3Plugin.YES;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.BUCKET;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.CREATE_DATATYPE;
|
||||
|
|
@ -20,6 +20,7 @@ import static com.external.plugins.constants.FieldName.CREATE_EXPIRY;
|
|||
import static com.external.plugins.constants.FieldName.LIST_SIGNED_URL;
|
||||
import static com.external.plugins.constants.FieldName.LIST_UNSIGNED_URL;
|
||||
import static com.external.plugins.constants.FieldName.LIST_WHERE;
|
||||
import static com.external.plugins.constants.FieldName.PATH;
|
||||
import static com.external.plugins.constants.FieldName.READ_DATATYPE;
|
||||
import static com.external.plugins.constants.FieldName.READ_EXPIRY;
|
||||
|
||||
|
|
@ -75,32 +76,18 @@ public class TemplateUtils {
|
|||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, COMMAND, AmazonS3Action.DELETE_MULTIPLE_FILES.name());
|
||||
setValueSafelyInFormData(configMap, BUCKET, bucketName);
|
||||
setValueSafelyInFormData(configMap, PATH, LIST_OF_FILES_STRING);
|
||||
|
||||
/**
|
||||
* Since S3 uses UQI interface, a config map is used to indicate the required template. However, some
|
||||
* properties like `actionConfiguration.path` cannot be configured via the config map since the config map only
|
||||
* models the formData attribute. Such properties are configured via ActionConfiguration object.
|
||||
*/
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setPath(LIST_OF_FILES_STRING);
|
||||
|
||||
return new Template(DELETE_MULTIPLE_FILES_TEMPLATE_NAME, configMap, actionConfiguration);
|
||||
return new Template(DELETE_MULTIPLE_FILES_TEMPLATE_NAME, configMap);
|
||||
}
|
||||
|
||||
private static Template getDeleteFileTemplate(String bucketName, String fileName) {
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, COMMAND, AmazonS3Action.DELETE_FILE.name());
|
||||
setValueSafelyInFormData(configMap, BUCKET, bucketName);
|
||||
setValueSafelyInFormData(configMap, PATH, fileName);
|
||||
|
||||
/**
|
||||
* Since S3 uses UQI interface, a config map is used to indicate the required template. However, some
|
||||
* properties like `actionConfiguration.path` cannot be configured via the config map since the config map only
|
||||
* models the formData attribute. Such properties are configured via ActionConfiguration object.
|
||||
*/
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setPath(fileName);
|
||||
|
||||
return new Template(DELETE_FILE_TEMPLATE_NAME, configMap, actionConfiguration);
|
||||
return new Template(DELETE_FILE_TEMPLATE_NAME, configMap);
|
||||
}
|
||||
|
||||
private static Template getReadFileTemplate(String bucketName, String fileName) {
|
||||
|
|
@ -109,16 +96,9 @@ public class TemplateUtils {
|
|||
setValueSafelyInFormData(configMap, BUCKET, bucketName);
|
||||
setValueSafelyInFormData(configMap, READ_DATATYPE, YES);
|
||||
setValueSafelyInFormData(configMap, READ_EXPIRY, DEFAULT_URL_EXPIRY_IN_MINUTES);
|
||||
setValueSafelyInFormData(configMap, PATH, fileName);
|
||||
|
||||
/**
|
||||
* Since S3 uses UQI interface, a config map is used to indicate the required template. However, some
|
||||
* properties like `actionConfiguration.path` cannot be configured via the config map since the config map only
|
||||
* models the formData attribute. Such properties are configured via ActionConfiguration object.
|
||||
*/
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setPath(fileName);
|
||||
|
||||
return new Template(READ_FILE_TEMPLATE_NAME, configMap, actionConfiguration);
|
||||
return new Template(READ_FILE_TEMPLATE_NAME, configMap);
|
||||
}
|
||||
|
||||
private static Template getCreateFileTemplate(String bucketName, String fileName) {
|
||||
|
|
@ -127,17 +107,10 @@ public class TemplateUtils {
|
|||
setValueSafelyInFormData(configMap, BUCKET, bucketName);
|
||||
setValueSafelyInFormData(configMap, CREATE_DATATYPE, YES);
|
||||
setValueSafelyInFormData(configMap, CREATE_EXPIRY, DEFAULT_URL_EXPIRY_IN_MINUTES);
|
||||
setValueSafelyInFormData(configMap, PATH, fileName);
|
||||
setValueSafelyInFormData(configMap, BODY, FILE_PICKER_DATA_EXPRESSION);
|
||||
|
||||
/**
|
||||
* Since S3 uses UQI interface, a config map is used to indicate the required template. However, some
|
||||
* properties like `actionConfiguration.path` cannot be configured via the config map since the config map only
|
||||
* models the formData attribute. Such properties are configured via ActionConfiguration object.
|
||||
*/
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setPath(fileName);
|
||||
actionConfiguration.setBody(FILE_PICKER_DATA_EXPRESSION);
|
||||
|
||||
return new Template(CREATE_FILE_TEMPLATE_NAME, configMap, actionConfiguration);
|
||||
return new Template(CREATE_FILE_TEMPLATE_NAME, configMap);
|
||||
}
|
||||
|
||||
private static Template getCreateMultipleFilesTemplate(String bucketName) {
|
||||
|
|
@ -146,17 +119,10 @@ public class TemplateUtils {
|
|||
setValueSafelyInFormData(configMap, BUCKET, bucketName);
|
||||
setValueSafelyInFormData(configMap, CREATE_DATATYPE, YES);
|
||||
setValueSafelyInFormData(configMap, CREATE_EXPIRY, DEFAULT_URL_EXPIRY_IN_MINUTES);
|
||||
setValueSafelyInFormData(configMap, PATH, DEFAULT_DIR);
|
||||
setValueSafelyInFormData(configMap, BODY, FILE_PICKER_MULTIPLE_FILES_DATA_EXPRESSION);
|
||||
|
||||
/**
|
||||
* Since S3 uses UQI interface, a config map is used to indicate the required template. However, some
|
||||
* properties like `actionConfiguration.path` cannot be configured via the config map since the config map only
|
||||
* models the formData attribute. Such properties are configured via ActionConfiguration object.
|
||||
*/
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setPath(DEFAULT_DIR);
|
||||
actionConfiguration.setBody(FILE_PICKER_MULTIPLE_FILES_DATA_EXPRESSION);
|
||||
|
||||
return new Template(CREATE_MULTIPLE_FILES_TEMPLATE_NAME, configMap, actionConfiguration);
|
||||
return new Template(CREATE_MULTIPLE_FILES_TEMPLATE_NAME, configMap);
|
||||
}
|
||||
|
||||
private static Template getListFilesTemplate(String bucketName) {
|
||||
|
|
@ -169,6 +135,6 @@ public class TemplateUtils {
|
|||
put("condition", "AND");
|
||||
}});
|
||||
|
||||
return new Template(LIST_FILES_TEMPLATE_NAME, configMap, new ActionConfiguration());
|
||||
return new Template(LIST_FILES_TEMPLATE_NAME, configMap);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1075,9 +1075,9 @@ public class AmazonS3PluginTest {
|
|||
// Check read file template
|
||||
Template readFileTemplate = templates.get(1);
|
||||
assertEquals(READ_FILE_TEMPLATE_NAME, readFileTemplate.getTitle());
|
||||
assertEquals(DEFAULT_FILE_NAME, readFileTemplate.getActionConfiguration().getPath());
|
||||
|
||||
Map<String, Object> readFileConfig = (Map<String, Object>) readFileTemplate.getConfiguration();
|
||||
assertEquals(DEFAULT_FILE_NAME, getValueSafelyFromFormData(readFileConfig, PATH));
|
||||
assertEquals(AmazonS3Action.READ_FILE.name(), getValueSafelyFromFormData(readFileConfig, COMMAND));
|
||||
assertEquals(expectedBucketName, getValueSafelyFromFormData(readFileConfig, BUCKET));
|
||||
assertEquals(YES, getValueSafelyFromFormData(readFileConfig, READ_DATATYPE));
|
||||
|
|
@ -1086,10 +1086,10 @@ public class AmazonS3PluginTest {
|
|||
// Check create file template
|
||||
Template createFileTemplate = templates.get(2);
|
||||
assertEquals(CREATE_FILE_TEMPLATE_NAME, createFileTemplate.getTitle());
|
||||
assertEquals(DEFAULT_FILE_NAME, createFileTemplate.getActionConfiguration().getPath());
|
||||
assertEquals(FILE_PICKER_DATA_EXPRESSION, createFileTemplate.getActionConfiguration().getBody());
|
||||
|
||||
Map<String, Object> createFileConfig = (Map<String, Object>) createFileTemplate.getConfiguration();
|
||||
assertEquals(DEFAULT_FILE_NAME, getValueSafelyFromFormData(createFileConfig, PATH));
|
||||
assertEquals(FILE_PICKER_DATA_EXPRESSION, getValueSafelyFromFormData(createFileConfig, BODY));
|
||||
assertEquals(AmazonS3Action.UPLOAD_FILE_FROM_BODY.name(),
|
||||
getValueSafelyFromFormData(createFileConfig, COMMAND));
|
||||
assertEquals(expectedBucketName, getValueSafelyFromFormData(createFileConfig, BUCKET));
|
||||
|
|
@ -1099,11 +1099,11 @@ public class AmazonS3PluginTest {
|
|||
// Check create multiple files template
|
||||
Template createMultipleFilesTemplate = templates.get(3);
|
||||
assertEquals(CREATE_MULTIPLE_FILES_TEMPLATE_NAME, createMultipleFilesTemplate.getTitle());
|
||||
assertEquals(DEFAULT_DIR, createMultipleFilesTemplate.getActionConfiguration().getPath());
|
||||
assertEquals(FILE_PICKER_MULTIPLE_FILES_DATA_EXPRESSION,
|
||||
createMultipleFilesTemplate.getActionConfiguration().getBody());
|
||||
|
||||
Map<String, Object> createMultipleFilesConfig = (Map<String, Object>) createMultipleFilesTemplate.getConfiguration();
|
||||
assertEquals(DEFAULT_DIR, getValueSafelyFromFormData(createMultipleFilesConfig, PATH));
|
||||
assertEquals(FILE_PICKER_MULTIPLE_FILES_DATA_EXPRESSION,
|
||||
getValueSafelyFromFormData(createMultipleFilesConfig, BODY));
|
||||
assertEquals(AmazonS3Action.UPLOAD_MULTIPLE_FILES_FROM_BODY.name(),
|
||||
getValueSafelyFromFormData(createMultipleFilesConfig, COMMAND));
|
||||
assertEquals(expectedBucketName, getValueSafelyFromFormData(createMultipleFilesConfig, BUCKET));
|
||||
|
|
@ -1113,9 +1113,9 @@ public class AmazonS3PluginTest {
|
|||
// Check delete file template
|
||||
Template deleteFileTemplate = templates.get(4);
|
||||
assertEquals(DELETE_FILE_TEMPLATE_NAME, deleteFileTemplate.getTitle());
|
||||
assertEquals(DEFAULT_FILE_NAME, deleteFileTemplate.getActionConfiguration().getPath());
|
||||
|
||||
Map<String, Object> deleteFileConfig = (Map<String, Object>) deleteFileTemplate.getConfiguration();
|
||||
assertEquals(DEFAULT_FILE_NAME, getValueSafelyFromFormData(deleteFileConfig, PATH));
|
||||
assertEquals(AmazonS3Action.DELETE_FILE.name(), getValueSafelyFromFormData(deleteFileConfig,
|
||||
COMMAND));
|
||||
assertEquals(expectedBucketName, getValueSafelyFromFormData(deleteFileConfig, BUCKET));
|
||||
|
|
@ -1123,10 +1123,10 @@ public class AmazonS3PluginTest {
|
|||
// Check delete multiple files template
|
||||
Template deleteMultipleFilesTemplate = templates.get(5);
|
||||
assertEquals(DELETE_MULTIPLE_FILES_TEMPLATE_NAME, deleteMultipleFilesTemplate.getTitle());
|
||||
assertEquals(LIST_OF_FILES_STRING, deleteMultipleFilesTemplate.getActionConfiguration().getPath());
|
||||
|
||||
Map<String, Object> deleteMultipleFilesConfig =
|
||||
(Map<String, Object>) deleteMultipleFilesTemplate.getConfiguration();
|
||||
assertEquals(LIST_OF_FILES_STRING, getValueSafelyFromFormData(deleteMultipleFilesConfig, PATH));
|
||||
assertEquals(AmazonS3Action.DELETE_MULTIPLE_FILES.name(),
|
||||
getValueSafelyFromFormData(deleteMultipleFilesConfig, COMMAND));
|
||||
assertEquals(expectedBucketName, getValueSafelyFromFormData(deleteMultipleFilesConfig, BUCKET));
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ public class MongoPlugin extends BasePlugin {
|
|||
smartBsonSubstitution = Boolean.parseBoolean((String) smartSubstitutionObject);
|
||||
}
|
||||
|
||||
// Smartly substitute in actionConfiguration.body and replace all the bindings with values.
|
||||
// Smartly substitute in formData.body and replace all the bindings with values.
|
||||
if (TRUE.equals(smartBsonSubstitution)) {
|
||||
|
||||
// If not raw, then it must be form input.
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresen
|
|||
import static com.external.plugins.constants.FieldName.AGGREGATE;
|
||||
import static com.external.plugins.constants.FieldName.AGGREGATE_LIMIT;
|
||||
import static com.external.plugins.constants.FieldName.AGGREGATE_PIPELINES;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COLLECTION;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.SMART_SUBSTITUTION;
|
||||
|
|
@ -123,17 +124,17 @@ public class Aggregate extends MongoCommand {
|
|||
setValueSafelyInFormData(configMap, AGGREGATE_PIPELINES, "[ {\"$sort\" : {\"_id\": 1} } ]");
|
||||
setValueSafelyInFormData(configMap, AGGREGATE_LIMIT, "10");
|
||||
|
||||
|
||||
String rawQuery = "{\n" +
|
||||
" \"aggregate\": \"" + collectionName + "\",\n" +
|
||||
" \"pipeline\": " + "[ {\"$sort\" : {\"_id\": 1} } ],\n" +
|
||||
" \"limit\": 10,\n" +
|
||||
" \"explain\": \"true\"\n" + // Specifies to return the information on the processing of the pipeline. (This also avoids the use of the 'cursor' aggregate key according to Mongo doc)
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
return Collections.singletonList(new DatasourceStructure.Template(
|
||||
"Aggregate",
|
||||
rawQuery,
|
||||
null,
|
||||
configMap
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import java.util.Map;
|
|||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresentInFormData;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COLLECTION;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.COUNT;
|
||||
|
|
@ -69,10 +70,11 @@ public class Count extends MongoCommand {
|
|||
" \"count\": \"" + collectionName + "\",\n" +
|
||||
" \"query\": " + "{\"_id\": {\"$exists\": true}} \n" +
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
return Collections.singletonList(new DatasourceStructure.Template(
|
||||
"Count",
|
||||
rawQuery,
|
||||
null,
|
||||
configMap
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import java.util.Map;
|
|||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresentInFormData;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COLLECTION;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.DELETE;
|
||||
|
|
@ -105,10 +106,11 @@ public class Delete extends MongoCommand {
|
|||
" }\n" +
|
||||
" ]\n" +
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
return Collections.singletonList(new DatasourceStructure.Template(
|
||||
"Delete",
|
||||
rawQuery,
|
||||
null,
|
||||
configMap
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import java.util.Map;
|
|||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresentInFormData;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COLLECTION;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.DISTINCT;
|
||||
|
|
@ -51,7 +52,7 @@ public class Distinct extends MongoCommand {
|
|||
if (!StringUtils.isNullOrEmpty(key)) {
|
||||
return Boolean.TRUE;
|
||||
} else if (StringUtils.isNullOrEmpty(key)) {
|
||||
fieldNamesWithNoConfiguration.add("Key/Field");
|
||||
fieldNamesWithNoConfiguration.add("Key/Field");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -92,13 +93,12 @@ public class Distinct extends MongoCommand {
|
|||
" \"query\": { \"_id\": ObjectId(\"id_of_document_to_distinct\") }," +
|
||||
" \"key\": \"_id\"," +
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
|
||||
|
||||
return Collections.singletonList(new DatasourceStructure.Template(
|
||||
"Distinct",
|
||||
rawQuery,
|
||||
configMap
|
||||
));
|
||||
return Collections.singletonList(new DatasourceStructure.Template(
|
||||
"Distinct",
|
||||
null,
|
||||
configMap
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import java.util.Map;
|
|||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresentInFormData;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COLLECTION;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.FIND;
|
||||
|
|
@ -139,10 +140,11 @@ public class Find extends MongoCommand {
|
|||
" },\n" +
|
||||
" \"limit\": 10\n" +
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
return new DatasourceStructure.Template(
|
||||
"Find",
|
||||
rawQuery,
|
||||
null,
|
||||
configMap
|
||||
);
|
||||
}
|
||||
|
|
@ -161,10 +163,11 @@ public class Find extends MongoCommand {
|
|||
" \"_id\": ObjectId(\"id_to_query_with\")\n" +
|
||||
" }\n" +
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
return new DatasourceStructure.Template(
|
||||
"Find by ID",
|
||||
rawQuery,
|
||||
null,
|
||||
configMap
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.util.stream.Collectors;
|
|||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresentInFormData;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COLLECTION;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.INSERT;
|
||||
|
|
@ -114,10 +115,11 @@ public class Insert extends MongoCommand {
|
|||
" }\n" +
|
||||
" ]\n" +
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
return Collections.singletonList(new DatasourceStructure.Template(
|
||||
"Insert",
|
||||
rawQuery,
|
||||
null,
|
||||
configMap
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import java.util.Map;
|
|||
import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData;
|
||||
import static com.appsmith.external.helpers.PluginUtils.validConfigurationPresentInFormData;
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COLLECTION;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.SMART_SUBSTITUTION;
|
||||
|
|
@ -122,10 +123,11 @@ public class UpdateMany extends MongoCommand {
|
|||
" }\n" +
|
||||
" ]\n" +
|
||||
"}\n";
|
||||
setValueSafelyInFormData(configMap, BODY, rawQuery);
|
||||
|
||||
return Collections.singletonList(new DatasourceStructure.Template(
|
||||
"Update",
|
||||
rawQuery,
|
||||
null,
|
||||
configMap
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import java.util.HashMap;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.external.plugins.constants.FieldName.BODY;
|
||||
import static com.external.plugins.constants.FieldName.COMMAND;
|
||||
import static com.external.plugins.constants.FieldName.RAW;
|
||||
|
||||
|
|
@ -92,7 +93,7 @@ public class MongoPluginUtils {
|
|||
|
||||
// We reached here. This means either this is a RAW command input or some configuration error has happened
|
||||
// in which case, we default to RAW
|
||||
return actionConfiguration.getBody();
|
||||
return (String) PluginUtils.getValueSafelyFromFormData(formData, BODY);
|
||||
}
|
||||
|
||||
public static String getDatabaseName(DatasourceConfiguration datasourceConfiguration) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"actionConfiguration.body": [
|
||||
"actionConfiguration.formData.smartSubstitution"
|
||||
"actionConfiguration.formData.body.data": [
|
||||
"actionConfiguration.formData.smartSubstitution.data"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -255,16 +255,16 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" filter: { \"age\": { \"$gte\": 30 } },\n" +
|
||||
" sort: { id: 1 },\n" +
|
||||
" limit: 10,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn, new ExecuteActionDTO(), dsConfig, actionConfiguration));
|
||||
|
|
@ -288,7 +288,7 @@ public class MongoPluginTest {
|
|||
*/
|
||||
List<RequestParamDTO> expectedRequestParams = new ArrayList<>();
|
||||
expectedRequestParams.add(new RequestParamDTO(ACTION_CONFIGURATION_BODY,
|
||||
actionConfiguration.getBody(), null, null, null));
|
||||
getValueSafelyFromFormData(actionConfiguration.getFormData(), BODY), null, null, null));
|
||||
assertEquals(result.getRequest().getRequestParams().toString(), expectedRequestParams.toString());
|
||||
})
|
||||
.verifyComplete();
|
||||
|
|
@ -300,16 +300,16 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" filter: { $is: {} },\n" +
|
||||
" sort: { id: 1 },\n" +
|
||||
" limit: 10,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn, new ExecuteActionDTO(), dsConfig, actionConfiguration));
|
||||
|
|
@ -329,7 +329,7 @@ public class MongoPluginTest {
|
|||
*/
|
||||
List<RequestParamDTO> expectedRequestParams = new ArrayList<>();
|
||||
expectedRequestParams.add(new RequestParamDTO(ACTION_CONFIGURATION_BODY,
|
||||
actionConfiguration.getBody(), null, null, null));
|
||||
getValueSafelyFromFormData(actionConfiguration.getFormData(), BODY), null, null, null));
|
||||
assertEquals(result.getRequest().getRequestParams().toString(), expectedRequestParams.toString());
|
||||
})
|
||||
.verifyComplete();
|
||||
|
|
@ -341,7 +341,11 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" insert: \"users\",\n" +
|
||||
" documents: [\n" +
|
||||
" {\n" +
|
||||
|
|
@ -352,10 +356,6 @@ public class MongoPluginTest {
|
|||
" },\n" +
|
||||
" ],\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn, new ExecuteActionDTO(), dsConfig, actionConfiguration));
|
||||
|
|
@ -392,7 +392,11 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" findAndModify: \"users\",\n" +
|
||||
" query: " +
|
||||
"{ " +
|
||||
|
|
@ -400,10 +404,6 @@ public class MongoPluginTest {
|
|||
" },\n" +
|
||||
" update: { $set: { gender: \"F\" }}\n" +
|
||||
"}");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn, new ExecuteActionDTO(), dsConfig, actionConfiguration));
|
||||
|
|
@ -433,14 +433,14 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" limit: 1,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" limit: 1,\n" +
|
||||
" }");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn, new ExecuteActionDTO(), dsConfig, actionConfiguration));
|
||||
|
|
@ -503,58 +503,47 @@ public class MongoPluginTest {
|
|||
|
||||
//Assert Find command
|
||||
DatasourceStructure.Template findTemplate = templates.get(0);
|
||||
assertEquals(findTemplate.getTitle(), "Find");
|
||||
assertEquals(findTemplate.getBody(), "{\n" +
|
||||
" \"find\": \"users\",\n" +
|
||||
" \"filter\": {\n" +
|
||||
" \"gender\": \"F\"\n" +
|
||||
" },\n" +
|
||||
" \"sort\": {\n" +
|
||||
" \"_id\": 1\n" +
|
||||
" },\n" +
|
||||
" \"limit\": 10\n" +
|
||||
"}\n");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) findTemplate.getConfiguration(), COMMAND), "FIND");
|
||||
assertEquals("Find", findTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"find\": \"users\",\n" +
|
||||
" \"filter\": {\n" +
|
||||
" \"gender\": \"F\"\n" +
|
||||
" },\n" +
|
||||
" \"sort\": {\n" +
|
||||
" \"_id\": 1\n" +
|
||||
" },\n" +
|
||||
" \"limit\": 10\n" +
|
||||
"}\n",
|
||||
getValueSafelyFromFormData((Map<String, Object>) findTemplate.getConfiguration(), BODY));
|
||||
assertEquals("FIND", getValueSafelyFromFormData((Map<String, Object>) findTemplate.getConfiguration(), COMMAND));
|
||||
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) findTemplate.getConfiguration(), FIND_QUERY),
|
||||
"{ \"gender\": \"F\"}");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) findTemplate.getConfiguration(), FIND_SORT),
|
||||
"{\"_id\": 1}");
|
||||
assertEquals("{ \"gender\": \"F\"}",
|
||||
getValueSafelyFromFormData((Map<String, Object>) findTemplate.getConfiguration(), FIND_QUERY));
|
||||
assertEquals("{\"_id\": 1}",
|
||||
getValueSafelyFromFormData((Map<String, Object>) findTemplate.getConfiguration(), FIND_SORT));
|
||||
|
||||
//Assert Find By Id command
|
||||
DatasourceStructure.Template findByIdTemplate = templates.get(1);
|
||||
assertEquals(findByIdTemplate.getTitle(), "Find by ID");
|
||||
assertEquals(findByIdTemplate.getBody(), "{\n" +
|
||||
" \"find\": \"users\",\n" +
|
||||
" \"filter\": {\n" +
|
||||
" \"_id\": ObjectId(\"id_to_query_with\")\n" +
|
||||
" }\n" +
|
||||
"}\n");
|
||||
assertEquals( getValueSafelyFromFormData((Map<String, Object>) findByIdTemplate.getConfiguration(), COMMAND), "FIND");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) findByIdTemplate.getConfiguration(), FIND_QUERY),
|
||||
"{\"_id\": ObjectId(\"id_to_query_with\")}");
|
||||
assertEquals("Find by ID", findByIdTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"find\": \"users\",\n" +
|
||||
" \"filter\": {\n" +
|
||||
" \"_id\": ObjectId(\"id_to_query_with\")\n" +
|
||||
" }\n" +
|
||||
"}\n",
|
||||
getValueSafelyFromFormData((Map<String, Object>) findByIdTemplate.getConfiguration(), BODY));
|
||||
assertEquals("FIND", getValueSafelyFromFormData((Map<String, Object>) findByIdTemplate.getConfiguration(), COMMAND));
|
||||
assertEquals("{\"_id\": ObjectId(\"id_to_query_with\")}",
|
||||
getValueSafelyFromFormData((Map<String, Object>) findByIdTemplate.getConfiguration(), FIND_QUERY));
|
||||
|
||||
// Assert Insert command
|
||||
DatasourceStructure.Template insertTemplate = templates.get(2);
|
||||
assertEquals(insertTemplate.getTitle(), "Insert");
|
||||
assertEquals(insertTemplate.getBody(), "{\n" +
|
||||
" \"insert\": \"users\",\n" +
|
||||
" \"documents\": [\n" +
|
||||
" {\n" +
|
||||
" \"_id\": ObjectId(\"a_valid_object_id_hex\"),\n" +
|
||||
" \"age\": 1,\n" +
|
||||
" \"dob\": new Date(\"2019-07-01\"),\n" +
|
||||
" \"gender\": \"new value\",\n" +
|
||||
" \"luckyNumber\": NumberLong(\"1\"),\n" +
|
||||
" \"name\": \"new value\",\n" +
|
||||
" \"netWorth\": NumberDecimal(\"1\"),\n" +
|
||||
" \"updatedByCommand\": {},\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}\n");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) insertTemplate.getConfiguration(),COMMAND), "INSERT");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) insertTemplate.getConfiguration(), INSERT_DOCUMENT),
|
||||
"[{ \"_id\": ObjectId(\"a_valid_object_id_hex\"),\n" +
|
||||
assertEquals("Insert", insertTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"insert\": \"users\",\n" +
|
||||
" \"documents\": [\n" +
|
||||
" {\n" +
|
||||
" \"_id\": ObjectId(\"a_valid_object_id_hex\"),\n" +
|
||||
" \"age\": 1,\n" +
|
||||
" \"dob\": new Date(\"2019-07-01\"),\n" +
|
||||
" \"gender\": \"new value\",\n" +
|
||||
|
|
@ -562,12 +551,26 @@ public class MongoPluginTest {
|
|||
" \"name\": \"new value\",\n" +
|
||||
" \"netWorth\": NumberDecimal(\"1\"),\n" +
|
||||
" \"updatedByCommand\": {},\n" +
|
||||
"}]");
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}\n",
|
||||
getValueSafelyFromFormData((Map<String, Object>) insertTemplate.getConfiguration(), BODY));
|
||||
assertEquals("INSERT", getValueSafelyFromFormData((Map<String, Object>) insertTemplate.getConfiguration(), COMMAND));
|
||||
assertEquals("[{ \"_id\": ObjectId(\"a_valid_object_id_hex\"),\n" +
|
||||
" \"age\": 1,\n" +
|
||||
" \"dob\": new Date(\"2019-07-01\"),\n" +
|
||||
" \"gender\": \"new value\",\n" +
|
||||
" \"luckyNumber\": NumberLong(\"1\"),\n" +
|
||||
" \"name\": \"new value\",\n" +
|
||||
" \"netWorth\": NumberDecimal(\"1\"),\n" +
|
||||
" \"updatedByCommand\": {},\n" +
|
||||
"}]",
|
||||
getValueSafelyFromFormData((Map<String, Object>) insertTemplate.getConfiguration(), INSERT_DOCUMENT));
|
||||
|
||||
// Assert Update command
|
||||
DatasourceStructure.Template updateTemplate = templates.get(3);
|
||||
assertEquals(updateTemplate.getTitle(), "Update");
|
||||
assertEquals(updateTemplate.getBody(), "{\n" +
|
||||
assertEquals("Update", updateTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"update\": \"users\",\n" +
|
||||
" \"updates\": [\n" +
|
||||
" {\n" +
|
||||
|
|
@ -577,17 +580,17 @@ public class MongoPluginTest {
|
|||
" \"u\": { \"$set\": { \"gender\": \"new value\" } }\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}\n");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) updateTemplate.getConfiguration(),COMMAND), "UPDATE");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) updateTemplate.getConfiguration(), UPDATE_QUERY),
|
||||
"{ \"_id\": ObjectId(\"id_of_document_to_update\") }");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) updateTemplate.getConfiguration(), UPDATE_OPERATION),
|
||||
"{ \"$set\": { \"gender\": \"new value\" } }");
|
||||
"}\n", getValueSafelyFromFormData((Map<String, Object>) updateTemplate.getConfiguration(), BODY));
|
||||
assertEquals("UPDATE", getValueSafelyFromFormData((Map<String, Object>) updateTemplate.getConfiguration(), COMMAND));
|
||||
assertEquals("{ \"_id\": ObjectId(\"id_of_document_to_update\") }",
|
||||
getValueSafelyFromFormData((Map<String, Object>) updateTemplate.getConfiguration(), UPDATE_QUERY));
|
||||
assertEquals("{ \"$set\": { \"gender\": \"new value\" } }",
|
||||
getValueSafelyFromFormData((Map<String, Object>) updateTemplate.getConfiguration(), UPDATE_OPERATION));
|
||||
|
||||
// Assert Delete Command
|
||||
DatasourceStructure.Template deleteTemplate = templates.get(4);
|
||||
assertEquals(deleteTemplate.getTitle(), "Delete");
|
||||
assertEquals(deleteTemplate.getBody(), "{\n" +
|
||||
assertEquals("Delete", deleteTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"delete\": \"users\",\n" +
|
||||
" \"deletes\": [\n" +
|
||||
" {\n" +
|
||||
|
|
@ -597,51 +600,51 @@ public class MongoPluginTest {
|
|||
" \"limit\": 1\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}\n");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) deleteTemplate.getConfiguration(),COMMAND), "DELETE");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) deleteTemplate.getConfiguration(), DELETE_QUERY),
|
||||
"{ \"_id\": ObjectId(\"id_of_document_to_delete\") }");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) deleteTemplate.getConfiguration(), DELETE_LIMIT),
|
||||
"SINGLE");
|
||||
"}\n", getValueSafelyFromFormData((Map<String, Object>) deleteTemplate.getConfiguration(), BODY));
|
||||
assertEquals("DELETE", getValueSafelyFromFormData((Map<String, Object>) deleteTemplate.getConfiguration(), COMMAND));
|
||||
assertEquals("{ \"_id\": ObjectId(\"id_of_document_to_delete\") }",
|
||||
getValueSafelyFromFormData((Map<String, Object>) deleteTemplate.getConfiguration(), DELETE_QUERY));
|
||||
assertEquals("SINGLE",
|
||||
getValueSafelyFromFormData((Map<String, Object>) deleteTemplate.getConfiguration(), DELETE_LIMIT));
|
||||
|
||||
// Assert Count Command
|
||||
DatasourceStructure.Template countTemplate = templates.get(5);
|
||||
assertEquals(countTemplate.getTitle(), "Count");
|
||||
assertEquals(countTemplate.getBody(), "{\n" +
|
||||
" \"count\": \"users\",\n" +
|
||||
" \"query\": " + "{\"_id\": {\"$exists\": true}} \n" +
|
||||
"}\n");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) countTemplate.getConfiguration(),COMMAND), "COUNT");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) countTemplate.getConfiguration(), COUNT_QUERY),
|
||||
"{\"_id\": {\"$exists\": true}}");
|
||||
assertEquals("Count", countTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"count\": \"users\",\n" +
|
||||
" \"query\": " + "{\"_id\": {\"$exists\": true}} \n" +
|
||||
"}\n", getValueSafelyFromFormData((Map<String, Object>) countTemplate.getConfiguration(), BODY));
|
||||
assertEquals("COUNT", getValueSafelyFromFormData((Map<String, Object>) countTemplate.getConfiguration(), COMMAND));
|
||||
assertEquals("{\"_id\": {\"$exists\": true}}",
|
||||
getValueSafelyFromFormData((Map<String, Object>) countTemplate.getConfiguration(), COUNT_QUERY));
|
||||
|
||||
// Assert Distinct Command
|
||||
DatasourceStructure.Template distinctTemplate = templates.get(6);
|
||||
assertEquals(distinctTemplate.getTitle(), "Distinct");
|
||||
assertEquals(distinctTemplate.getBody(), "{\n" +
|
||||
" \"distinct\": \"users\",\n" +
|
||||
" \"query\": { \"_id\": ObjectId(\"id_of_document_to_distinct\") }," +
|
||||
" \"key\": \"_id\"," +
|
||||
"}\n");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) distinctTemplate.getConfiguration(),COMMAND), "DISTINCT");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) distinctTemplate.getConfiguration(), DISTINCT_QUERY),
|
||||
"{ \"_id\": ObjectId(\"id_of_document_to_distinct\") }");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) distinctTemplate.getConfiguration(), DISTINCT_KEY),
|
||||
"_id");
|
||||
assertEquals("Distinct", distinctTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"distinct\": \"users\",\n" +
|
||||
" \"query\": { \"_id\": ObjectId(\"id_of_document_to_distinct\") }," +
|
||||
" \"key\": \"_id\"," +
|
||||
"}\n", getValueSafelyFromFormData((Map<String, Object>) distinctTemplate.getConfiguration(), BODY));
|
||||
assertEquals("DISTINCT", getValueSafelyFromFormData((Map<String, Object>) distinctTemplate.getConfiguration(), COMMAND));
|
||||
assertEquals("{ \"_id\": ObjectId(\"id_of_document_to_distinct\") }",
|
||||
getValueSafelyFromFormData((Map<String, Object>) distinctTemplate.getConfiguration(), DISTINCT_QUERY));
|
||||
assertEquals("_id",
|
||||
getValueSafelyFromFormData((Map<String, Object>) distinctTemplate.getConfiguration(), DISTINCT_KEY));
|
||||
|
||||
// Assert Aggregate Command
|
||||
DatasourceStructure.Template aggregateTemplate = templates.get(7);
|
||||
assertEquals(aggregateTemplate.getTitle(), "Aggregate");
|
||||
assertEquals(aggregateTemplate.getBody(), "{\n" +
|
||||
" \"aggregate\": \"users\",\n" +
|
||||
" \"pipeline\": " + "[ {\"$sort\" : {\"_id\": 1} } ],\n" +
|
||||
" \"limit\": 10,\n" +
|
||||
" \"explain\": \"true\"\n" +
|
||||
"}\n");
|
||||
assertEquals("Aggregate", aggregateTemplate.getTitle());
|
||||
assertEquals("{\n" +
|
||||
" \"aggregate\": \"users\",\n" +
|
||||
" \"pipeline\": " + "[ {\"$sort\" : {\"_id\": 1} } ],\n" +
|
||||
" \"limit\": 10,\n" +
|
||||
" \"explain\": \"true\"\n" +
|
||||
"}\n", getValueSafelyFromFormData((Map<String, Object>) aggregateTemplate.getConfiguration(), BODY));
|
||||
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) aggregateTemplate.getConfiguration(), COMMAND), "AGGREGATE");
|
||||
assertEquals(getValueSafelyFromFormData((Map<String, Object>) aggregateTemplate.getConfiguration(), AGGREGATE_PIPELINES),
|
||||
"[ {\"$sort\" : {\"_id\": 1} } ]");
|
||||
assertEquals("AGGREGATE", getValueSafelyFromFormData((Map<String, Object>) aggregateTemplate.getConfiguration(), COMMAND));
|
||||
assertEquals("[ {\"$sort\" : {\"_id\": 1} } ]",
|
||||
getValueSafelyFromFormData((Map<String, Object>) aggregateTemplate.getConfiguration(), AGGREGATE_PIPELINES));
|
||||
|
||||
|
||||
})
|
||||
|
|
@ -831,16 +834,16 @@ public class MongoPluginTest {
|
|||
datasourceConfiguration.getConnection().getSsl().setAuthType(SSLDetails.AuthType.DEFAULT);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" filter: { age: { $gte: 30 } },\n" +
|
||||
" sort: { id: 1 },\n" +
|
||||
" limit: 10,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(datasourceConfiguration);
|
||||
|
|
@ -870,16 +873,16 @@ public class MongoPluginTest {
|
|||
datasourceConfiguration.getConnection().getSsl().setAuthType(SSLDetails.AuthType.DISABLED);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" filter: { age: { $gte: 30 } },\n" +
|
||||
" sort: { id: 1 },\n" +
|
||||
" limit: 10,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(datasourceConfiguration);
|
||||
|
|
@ -909,16 +912,16 @@ public class MongoPluginTest {
|
|||
datasourceConfiguration.getConnection().getSsl().setAuthType(SSLDetails.AuthType.ENABLED);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
actionConfiguration.setBody("{\n" +
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" filter: { age: { $gte: 30 } },\n" +
|
||||
" sort: { id: 1 },\n" +
|
||||
" limit: 10,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(datasourceConfiguration);
|
||||
|
|
@ -1799,16 +1802,16 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
// Set bad attribute for limit key
|
||||
actionConfiguration.setBody("{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" filter: \"filter\",\n" +
|
||||
" limit: 10,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
// Set bad attribute for limit key
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" filter: \"filter\",\n" +
|
||||
" limit: 10,\n" +
|
||||
" }");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn,
|
||||
|
|
@ -1833,15 +1836,15 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
// Set bad attribute for limit key
|
||||
actionConfiguration.setBody("{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" limit: [10],\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
// Set bad attribute for limit key
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" limit: [10],\n" +
|
||||
" }");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn,
|
||||
|
|
@ -1866,15 +1869,15 @@ public class MongoPluginTest {
|
|||
Mono<MongoClient> dsConnectionMono = pluginExecutor.datasourceCreate(dsConfig);
|
||||
|
||||
ActionConfiguration actionConfiguration = new ActionConfiguration();
|
||||
// Set unrecognized key limitx
|
||||
actionConfiguration.setBody("{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" limitx: 10,\n" +
|
||||
" }");
|
||||
|
||||
Map<String, Object> configMap = new HashMap<>();
|
||||
setValueSafelyInFormData(configMap, SMART_SUBSTITUTION, Boolean.TRUE);
|
||||
setValueSafelyInFormData(configMap, COMMAND, "RAW");
|
||||
// Set unrecognized key limitx
|
||||
setValueSafelyInFormData(configMap, BODY, "{\n" +
|
||||
" find: \"users\",\n" +
|
||||
" limitx: 10,\n" +
|
||||
" }");
|
||||
actionConfiguration.setFormData(configMap);
|
||||
|
||||
Mono<Object> executeMono = dsConnectionMono.flatMap(conn -> pluginExecutor.executeParameterized(conn,
|
||||
|
|
|
|||
|
|
@ -323,8 +323,9 @@ public class CreateDBTablePageSolutionCEImpl implements CreateDBTablePageSolutio
|
|||
// index 1 in plugin specified templates
|
||||
|
||||
if (Entity.S3_PLUGIN_PACKAGE_NAME.equals(plugin.getPackageName()) && !CollectionUtils.isEmpty(templateActionList)) {
|
||||
final Map<String, Object> formData = templateActionList.get(0).getUnpublishedAction().getActionConfiguration().getFormData();
|
||||
mappedColumnsAndTableName.put(
|
||||
(String) templateActionList.get(0).getUnpublishedAction().getActionConfiguration().getFormData().get("bucket"),
|
||||
(String) ((Map<?,?>)formData.get("bucket")).get("data"),
|
||||
tableName
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user