Skip to content

Commit

Permalink
Merge pull request #36 from eBay/byarger/update
Browse files Browse the repository at this point in the history
Fixing check viewer bug and addressing formatting.
  • Loading branch information
yarg0007 authored Jun 12, 2023
2 parents d309fcb + 5df31a4 commit 9e3e454
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions TMBuilder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Executable requires Java 8 or later. Download is available under [releases](http

| Version | Notes |
|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 3.1.2 | Fix check review bug and formatting. |
| 3.1.1 | Fix export developer mock dialog selection messaging. Eliminating confusion around the file filter referencing Java and Kotlin classes which are not necessary when exporting developer mocks. |
| 3.1.0 | Support Kotlin thin model classes. |
| 3.0.1 | Upgrade to GraphQL2JSONSchema library 1.1.2 to fix non nullable operation parsing. |
Expand Down
2 changes: 1 addition & 1 deletion TMBuilder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<modelVersion>4.0.0</modelVersion>
<artifactId>tmbuilder</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
<name>TMBuilder</name>
<description>Thin Model Builder (TMBuilder) for NST thin models.</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class TMGuiConstants {

public static final String APP_NAME = "TMBuilder v3.1.1";
public static final String APP_NAME = "TMBuilder v3.1.2";
public static final int DEFAULT_WINDOW_WIDTH = 1000;
public static final int DEFAULT_WINDOW_HEIGHT = 800;
public static final String DICTIONARY_KEY = "<key>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,17 +375,20 @@ private void doReviewValidationSet(String validationSetName) {

String message = "";
// Based on selected file format, choose the export Thin Model Export method
if(selectedFileFormat.equals(KOTLIN_FILE_EXTENSION))
if(KOTLIN_FILE_EXTENSION.equals(selectedFileFormat))
message = new KotlinThinModelExport().getValidationStatementsForValidationSet(setModel);
else
message = new ThinModelExport().getValidationStatementsForValidationSet(setModel);

message = message.replaceAll("\t", "").trim();
message = message.replaceAll(ExportConstants.GENERATED_TWO_TAB_SPACE, "").trim();
message = message.replaceAll(ExportConstants.GENERATED_TAB_SPACE, "").trim();

JTextPane validationTextArea = new JTextPane();
validationTextArea.setText(message);
validationTextArea.setEditable(false);
validationTextArea.setPreferredSize(new Dimension(validationTextArea.getPreferredSize().width, validationTextArea.getPreferredSize().height));
validationTextArea.setMaximumSize(new Dimension(100,200));

JScrollPane scrollPane = new JScrollPane(validationTextArea);
JOptionPane.showMessageDialog(MainWindow.getInstance(), scrollPane, String.format("Review Validation Set Output - %s", validationSetName), JOptionPane.INFORMATION_MESSAGE);
Expand Down Expand Up @@ -427,6 +430,7 @@ private void doReviewMock(String validationSetName) {
validationMock.setText(json);
validationMock.setEditable(false);
validationMock.setPreferredSize(new Dimension(validationMock.getPreferredSize().width, validationMock.getPreferredSize().height));
validationMock.setMaximumSize(new Dimension(100,200));

JScrollPane scrollPane = new JScrollPane(validationMock);
JOptionPane.showMessageDialog(MainWindow.getInstance(), scrollPane, String.format("Review Validation Set Output - %s", validationSetName), JOptionPane.INFORMATION_MESSAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

public class ExportConstants {
public static final String CORE_VALIDATION_SET = "coreValidation";
public static final String GENERATED_TWO_TAB_SPACE = " ";
public static final String GENERATED_TAB_SPACE = " ";
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public class KotlinThinModelExport {
private static final String GENERATED_VALIDATION_METHOD_CALL = "generatedValidations(softAssert)";
private static final String GENERATED_VALIDATION_METHOD_SIGNATURE = "generatedValidations(softAssert: SoftAssert)";
private static final String GENERATED_VALIDATIONS_START_BLOCK = "// TMB Generated Validation Method";
private static final String GENERATED_TWO_TAB_SPACE = " ";
private static final String GENERATED_TAB_SPACE = " ";

HashSet<String> imports = new HashSet<>();

Expand Down Expand Up @@ -133,7 +131,7 @@ private void updateFile(File exportFile, String validationStatements) throws IOE
insideValidationMethod = false;

if (!generatedValidationMethodCallExists) {
fileContents.append(String.format(GENERATED_TWO_TAB_SPACE + "%s\n", GENERATED_VALIDATION_METHOD_CALL));
fileContents.append(String.format(ExportConstants.GENERATED_TWO_TAB_SPACE + "%s\n", GENERATED_VALIDATION_METHOD_CALL));
generatedValidationMethodCallExists = true;
}
}
Expand Down Expand Up @@ -211,7 +209,7 @@ private String getValidationStatementsForNodeModels(List<NodeModel> nodeModels)
if (jsonPathExecutor instanceof ThinModelSerializer) {
String statements = ((ThinModelSerializer) jsonPathExecutor).getKotlinStatements();
savedJsonPath = savedJsonPath.replace("\"", "\\\"");
methodBuilder.append(String.format(GENERATED_TWO_TAB_SPACE + "validations[\"%s\"] = %s\n", savedJsonPath, statements));
methodBuilder.append(String.format(ExportConstants.GENERATED_TWO_TAB_SPACE + "validations[\"%s\"] = %s\n", savedJsonPath, statements));
}
}
}
Expand All @@ -225,7 +223,7 @@ private String prepareValidationStatements(List<ValidationSetModel> validationSe
String validationSetName = validationSetModel.getValidationSetName();
validationSetName = lowerCaseCamelCaseValidationSetName(validationSetName);
String methodSignature = validationSetName + "(softAssert: SoftAssert)";
allValidations.append(GENERATED_TAB_SPACE + GENERATED_VALIDATIONS_START_BLOCK);
allValidations.append(ExportConstants.GENERATED_TAB_SPACE + GENERATED_VALIDATIONS_START_BLOCK);
allValidations.append("\n");
allValidations.append(prepareMethodAndStatementsWithMethod(Arrays.asList(validationSetModel.getData()), methodSignature));
allValidations.append("\n");
Expand All @@ -238,16 +236,16 @@ private String prepareMethodAndStatementsWithMethod(List<NodeModel> nodeModels,
String convertedMethod = coreValidation ? GENERATED_VALIDATION_METHOD_SIGNATURE : methodName;
String accessModifier = coreValidation ? "private" : "";

StringBuilder methodBuilder = new StringBuilder(String.format(GENERATED_TAB_SPACE + "%s fun %s {\n", accessModifier, convertedMethod));
methodBuilder.append(GENERATED_TWO_TAB_SPACE + "val validations: MutableMap<String, JsonPathExecutor> = HashMap()\n");
StringBuilder methodBuilder = new StringBuilder(String.format(ExportConstants.GENERATED_TAB_SPACE + "%s fun %s {\n", accessModifier, convertedMethod));
methodBuilder.append(ExportConstants.GENERATED_TWO_TAB_SPACE + "val validations: MutableMap<String, JsonPathExecutor> = HashMap()\n");
methodBuilder.append(getValidationStatementsForNodeModels(nodeModels));
methodBuilder.append(GENERATED_TWO_TAB_SPACE + "evaluateJsonPaths(validations, softAssert)\n");
methodBuilder.append(ExportConstants.GENERATED_TWO_TAB_SPACE + "evaluateJsonPaths(validations, softAssert)\n");

if (!coreValidation) {
methodBuilder.append("\t\tsoftAssert.assertAll();").append("\n");
}

methodBuilder.append(GENERATED_TAB_SPACE + "}");
methodBuilder.append(ExportConstants.GENERATED_TAB_SPACE + "}");

return methodBuilder.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public class ThinModelExport {
private static final String GENERATED_VALIDATION_METHOD_CALL = "generatedValidations(softAssert)";
private static final String GENERATED_VALIDATION_METHOD_SIGNATURE = "generatedValidations(SoftAssert softAssert)";
private static final String GENERATED_VALIDATIONS_START_BLOCK = "// TMB Generated Validation Method";
private static final String GENERATED_TWO_TAB_SPACE = " ";
private static final String GENERATED_TAB_SPACE = " ";

HashSet<String> imports = new HashSet<>();

Expand Down Expand Up @@ -118,7 +116,7 @@ private void updateFile(File exportFile, String validationStatements) throws IOE
insideValidationMethod = false;

if (!generatedValidationMethodCallExists) {
fileContents.append(String.format(GENERATED_TWO_TAB_SPACE+"%s;\n", GENERATED_VALIDATION_METHOD_CALL));
fileContents.append(String.format(ExportConstants.GENERATED_TWO_TAB_SPACE+"%s;\n", GENERATED_VALIDATION_METHOD_CALL));
generatedValidationMethodCallExists = true;
}
}
Expand Down Expand Up @@ -196,7 +194,7 @@ private String getValidationStatementsForNodeModels(List<NodeModel> nodeModels)
if (jsonPathExecutor instanceof ThinModelSerializer) {
String statements = ((ThinModelSerializer) jsonPathExecutor).getJavaStatements();
savedJsonPath = savedJsonPath.replace("\"", "\\\"");
methodBuilder.append(String.format(GENERATED_TWO_TAB_SPACE+"validations.put(\"%s\", %s);\n", savedJsonPath, statements));
methodBuilder.append(String.format(ExportConstants.GENERATED_TWO_TAB_SPACE+"validations.put(\"%s\", %s);\n", savedJsonPath, statements));
}
}
}
Expand All @@ -211,7 +209,7 @@ private String prepareValidationStatements(List<ValidationSetModel> validationSe
String validationSetName = validationSetModel.getValidationSetName();
validationSetName = lowerCaseCamelCaseValidationSetName(validationSetName);
String methodSignature = validationSetName + "(SoftAssert softAssert)";
allValidations.append(GENERATED_TAB_SPACE+GENERATED_VALIDATIONS_START_BLOCK);
allValidations.append(ExportConstants.GENERATED_TAB_SPACE+GENERATED_VALIDATIONS_START_BLOCK);
allValidations.append("\n");
allValidations.append(prepareMethodAndStatementsWithMethod(Arrays.asList(validationSetModel.getData()), methodSignature));
allValidations.append("\n");
Expand All @@ -225,16 +223,16 @@ private String prepareMethodAndStatementsWithMethod(List<NodeModel> nodeModels,
String convertedMethod = coreValidation ? GENERATED_VALIDATION_METHOD_SIGNATURE : methodName;
String accessModifier = coreValidation ? "private" : "public";

StringBuilder methodBuilder = new StringBuilder(String.format(GENERATED_TAB_SPACE+"%s void %s {\n", accessModifier, convertedMethod));
methodBuilder.append(GENERATED_TWO_TAB_SPACE+"Map<String, JsonPathExecutor> validations = new HashMap<>();\n");
StringBuilder methodBuilder = new StringBuilder(String.format(ExportConstants.GENERATED_TAB_SPACE+"%s void %s {\n", accessModifier, convertedMethod));
methodBuilder.append(ExportConstants.GENERATED_TWO_TAB_SPACE+"Map<String, JsonPathExecutor> validations = new HashMap<>();\n");
methodBuilder.append(getValidationStatementsForNodeModels(nodeModels));
methodBuilder.append(GENERATED_TWO_TAB_SPACE+"evaluateJsonPaths(validations, softAssert);\n");
methodBuilder.append(ExportConstants.GENERATED_TWO_TAB_SPACE+"evaluateJsonPaths(validations, softAssert);\n");

if (!coreValidation) {
methodBuilder.append("\t\tsoftAssert.assertAll();").append("\n");
}

methodBuilder.append(GENERATED_TAB_SPACE+"}");
methodBuilder.append(ExportConstants.GENERATED_TAB_SPACE+"}");

return methodBuilder.toString();
}
Expand Down

0 comments on commit 9e3e454

Please sign in to comment.