Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: automike <[email protected]>
  • Loading branch information
mikeliucc committed Feb 4, 2019
1 parent 5e79cdb commit 4d45207
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
30 changes: 18 additions & 12 deletions src/main/java/org/nexial/core/model/ExecutionSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,6 @@ public String toString() {
text.append(formatLabel("PASS")).append(formatStat(passCount, totalSteps));
text.append(formatLabel("FAIL")).append(formatStat(failCount, totalSteps));

//if (MapUtils.isNotEmpty(referenceData)) {
// StringBuffer refData = new StringBuffer();
// referenceData.forEach((key, value) -> refData.append(" [")
// .append(key).append("=")
// .append(referenceData.get(key))
// .append("]"));
// text.append(formatLabel("References")).append(formatValue(refData.toString()));
//}

return text.toString();
}

Expand Down Expand Up @@ -528,8 +519,14 @@ protected int createScenarioExecutionSummary(Worksheet sheet, ExecutionSummary s
if (MapUtils.isNotEmpty(ref)) {
List<String> refNames = CollectionUtil.toList(ref.keySet());
for (String name : refNames) {
if (StringUtils.isBlank(name)) { continue; }

String value = ref.get(name);
if (StringUtils.isEmpty(value)) { continue; }

// don't print empty/missing ref data
createCell(sheet, "B" + rowNum, name, STYLE_EXEC_SUMM_DATA_NAME, rowHeight);
createCell(sheet, "C" + rowNum, ref.get(name), STYLE_EXEC_SUMM_DATA_VALUE, rowHeight);
createCell(sheet, "C" + rowNum, value, STYLE_EXEC_SUMM_DATA_VALUE, rowHeight);
rowNum++;
}
} else {
Expand Down Expand Up @@ -647,10 +644,20 @@ protected static String formatDuration(long elapsedTime) {
}

protected void createTestExecutionSection(Worksheet sheet, int rowNum, String title, Map<String, String> data) {
// gotta make sure we don't print empty/missing ref.
if (MapUtils.isEmpty(data)) { return; }

List<String> names = CollectionUtil.toList(data.keySet());
names.forEach(name -> {
if (StringUtils.isBlank(name) || StringUtils.isEmpty(data.get(name))) { data.remove(name); }
});

if (MapUtils.isEmpty(data)) { return; }

float rowHeight = EXEC_SUMMARY_HEIGHT;
createCell(sheet, "A" + rowNum, title, STYLE_EXEC_SUMM_DATA_HEADER, rowHeight);

List<String> names = CollectionUtil.toList(data.keySet());
names = CollectionUtil.toList(data.keySet());
for (int i = 0; i < names.size(); i++) {
String name = names.get(i);
createCell(sheet, "B" + (i + rowNum), name, STYLE_EXEC_SUMM_DATA_NAME, rowHeight);
Expand All @@ -659,7 +666,6 @@ protected void createTestExecutionSection(Worksheet sheet, int rowNum, String ti
String[] values = StringUtils.splitByWholeSeparator(value, "\n");
for (int j = 0; j < values.length; j++) {
String dataValue = values[j];
if (StringUtils.isBlank(dataValue)) { continue; }
createLinkCell(sheet, (char) ('C' + j) + "" + (i + rowNum), dataValue, STYLE_EXEC_SUMM_DATA_VALUE);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/nexial/core/tools/NexialSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import static javax.crypto.Cipher.ENCRYPT_MODE;
import static org.nexial.core.NexialConst.*;
import static org.nexial.core.NexialConst.ExitStatus.*;
import static org.nexial.core.utils.ExecUtils.BIN_SCRIPT_EXT;

/**
* This class is a utility for encrypting the setup/data file with the given key file passed as options
Expand Down Expand Up @@ -93,7 +94,7 @@ public final class NexialSetup {
private static final String ENCRYPTION_ALGORITHM = "AES";

private static final String MSG_MISSING_ENV = "Missing environment details. Please be sure to run via " +
"bin/nexial-setup.cmd or bin/nexial-setup.sh script";
"bin/nexial-setup" + BIN_SCRIPT_EXT + " script";
private static final String MSG_CANT_WRITE_TEMP = "Unable to read/write directory '" + TEMP + "' to generate " +
"setup artifacts. Please fix permission and re-run again.";
private static Options cmdOptions = initCmdOptions();
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/nexial/core/utils/ExecUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.nexial.commons.utils.DateUtility;
import org.nexial.core.Nexial;

import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.nexial.core.NexialConst.Data.DEF_TEXT_DELIM;
import static org.nexial.core.NexialConst.Data.SCRIPT_REF_PREFIX;
import static org.nexial.core.NexialConst.Integration.*;
Expand Down Expand Up @@ -71,6 +72,8 @@ public final class ExecUtils {

public static final List<String> JUNIT_CLASSES = Arrays.asList("org.junit.runner.JUnitCore",
"org.junit.runners.ParentRunner");
public static final String BIN_SCRIPT_EXT = (IS_OS_WINDOWS ? ".cmd" : ".sh");

public static String manifest;

private ExecUtils() {}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/org/nexial/core/utils/InputFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import static org.nexial.core.NexialConst.Data.DEF_OPEN_EXCEL_AS_DUP;
import static org.nexial.core.NexialConst.Data.SHEET_SYSTEM;
import static org.nexial.core.excel.ExcelConfig.*;
import static org.nexial.core.utils.ExecUtils.BIN_SCRIPT_EXT;

public final class InputFileUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(InputFileUtils.class);
Expand All @@ -50,13 +51,15 @@ public final class InputFileUtils {
ArrayUtils.toString(ADDR_HEADER_SCENARIO_INFO1) + "," +
ArrayUtils.toString(ADDR_HEADER_SCENARIO_INFO2) + "," +
ArrayUtils.toString(ADDR_HEADER_TEST_STEP) + "; please run " +
"bin/nexial-script-update.cmd to update your test script";
"bin/nexial-script-update" + BIN_SCRIPT_EXT +
" to update your test script";
private static final String MSG_HEADER_NOT_FOUND = "required script header NOT found at " +
ArrayUtils.toString(ADDR_HEADER_SCENARIO_INFO1) + "," +
ArrayUtils.toString(ADDR_HEADER_SCENARIO_INFO2);
private static final String MSG_V1_SCRIPT_HEADER = "Outdated format found at " +
ArrayUtils.toString(ADDR_HEADER_TEST_STEP) + "; please run " +
"bin/nexial-script-update.cmd to update your test script";
"bin/nexial-script-update" + BIN_SCRIPT_EXT +
" to update your test script";
private static final String MSG_SCRIPT_HEADER_NOT_FOUND = "required script header not found at " +
ArrayUtils.toString(ADDR_HEADER_TEST_STEP);
private static final String MSG_MISSING_TEST_ACTIVITY = "First test step must be accompanied by a test activity";
Expand Down

0 comments on commit 4d45207

Please sign in to comment.