Skip to content

Commit

Permalink
eCRF field ref - selenium test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrenn committed Feb 27, 2024
1 parent 2ccc4d0 commit 5762eca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Test case for method <code>getEcrfFieldValueCount</code> of service <code>InputFieldService</code>.
* </p>
*
* @see org.phoenixctms.ctsms.service.shared.InputFieldService#getEcrfFieldValueCount(org.phoenixctms.ctsms.vo.AuthenticationVO, java.lang.Long, java.lang.Long, boolean)
* @see org.phoenixctms.ctsms.service.shared.InputFieldService#getEcrfFieldValueCount(org.phoenixctms.ctsms.vo.AuthenticationVO, java.lang.Long, boolean)
*/
@Test(groups={"service","InputFieldService"})
public class InputFieldService_getEcrfFieldValueCountTest extends InputFieldServiceBaseTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ public class EcrfValidationRowProcessor extends RowProcessor {
private final static String SHEET_NAME = "validation";
private final static int ECRF_NAME_COLUMN_INDEX = 0;
private final static int ECRF_REVISION_COLUMN_INDEX = 1;
private final static int SECTION_COLUMN_INDEX = 2;
private final static int POSITION_COLUMN_INDEX = 3;
private final static int INDEX_COLUMN_INDEX = 4;
private final static int INPUT_VALUE_COLUMN_INDEX = 5;
private final static int EXPORTED_VALUE_COLUMN_INDEX = 6;
private final static int EXPECTED_OUTPUT_COLUMN_INDEX = 7;
private final static int REF_COLUMN_INDEX = 2;
private final static int INDEX_COLUMN_INDEX = 3;
private final static int INPUT_VALUE_COLUMN_INDEX = 4;
private final static int EXPORTED_VALUE_COLUMN_INDEX = 5;
private final static int EXPECTED_OUTPUT_COLUMN_INDEX = 6;
private int ecrfNameColumnIndex;
private int ecrfRevisionColumnIndex;
private int sectionColumnIndex;
private int positionColumnIndex;
private int refColumnIndex;
private int indexColumnIndex;
private int inputValueColumnIndex;
private int exportedValueColumnIndex;
Expand All @@ -43,8 +41,6 @@ public class EcrfValidationRowProcessor extends RowProcessor {
protected ECRFDao eCRFDao; // varnames must match bean ids in applicationContext.xml
@Autowired
protected ECRFFieldDao eCRFFieldDao;
//@Autowired
//protected InputFieldDao inputFieldDao;
@Autowired
protected TrialService trialService;

Expand Down Expand Up @@ -107,16 +103,6 @@ private String getEcrfRevision(String[] values) {
private String getEcrfName(String[] values) {
return getColumnValue(values, ecrfNameColumnIndex);
}
// private Long getInputFieldId(String inputFieldName) {
// InputField inputField = ((XlsImporter) context.getImporter()).getSelectionSetValueRowProcessor().getInputField(inputFieldName);
// Long fieldId = null;
// if (inputField != null) {
// fieldId = inputField.getId();
// } else {
// jobOutput.println("input field '" + inputFieldName + "' not found");
// }
// return fieldId;
// }

private String getInputValue(String[] values) {
return getColumnValue(values, inputValueColumnIndex);
Expand All @@ -130,18 +116,14 @@ private String getExpectedOutput(String[] values) {
return getColumnValue(values, expectedOutputColumnIndex);
}

private String getPosition(String[] values) {
return getColumnValue(values, positionColumnIndex);
private String getRef(String[] values) {
return getColumnValue(values, refColumnIndex);
}

private String getIndex(String[] values) {
return getColumnValue(values, indexColumnIndex);
}

private String getSection(String[] values) {
return getColumnValue(values, sectionColumnIndex);
}

@Override
public String getSheetName() {
return SHEET_NAME;
Expand All @@ -152,25 +134,22 @@ public void init() throws Throwable {
super.init();
ecrfNameColumnIndex = ECRF_NAME_COLUMN_INDEX;
ecrfRevisionColumnIndex = ECRF_REVISION_COLUMN_INDEX;
sectionColumnIndex = SECTION_COLUMN_INDEX;
positionColumnIndex = POSITION_COLUMN_INDEX;
refColumnIndex = REF_COLUMN_INDEX;
indexColumnIndex = INDEX_COLUMN_INDEX;
inputValueColumnIndex = INPUT_VALUE_COLUMN_INDEX;
exportedValueColumnIndex = EXPORTED_VALUE_COLUMN_INDEX;
expectedOutputColumnIndex = EXPECTED_OUTPUT_COLUMN_INDEX;
vectorMap.clear();
ecrfMap.clear();
vectors.clear();
// ((XlsImporter) context.getImporter()).loadInputFields(context);
}

@Override
protected int lineHashCode(String[] values) {
return new HashCodeBuilder(1249046965, -82296885)
.append(getEcrfName(values))
.append(getEcrfRevision(values))
.append(getSection(values))
.append(getPosition(values))
.append(getRef(values))
.append(getIndex(values))
.append(getInputValue(values))
.append(getExportedValue(values))
Expand All @@ -187,9 +166,8 @@ protected int processRow(String[] values, long rowNumber) throws Throwable {
String ecrfName = getEcrfName(values);
String ecrfRevision = getEcrfRevision(values);
ECRF ecrf = getEcrf(ecrfName, ecrfRevision);
Long position = Long.parseLong(getPosition(values));
String section = getSection(values);
ECRFField ecrfField = eCRFFieldDao.findByEcrfSectionPosition(ecrf.getId(), section, position).iterator().next();
String ref = getRef(values);
ECRFField ecrfField = eCRFFieldDao.findByEcrfRef(ecrf.getId(), ref).iterator().next();
ECRFFieldOutVO ecrfFieldVO = trialService.getEcrfField(context.getAuth(), ecrfField.getId());
List<EcrfValidationTestVector> ecrfVectors;
HashMap<String, List<EcrfValidationTestVector>> revisionMap;
Expand All @@ -206,7 +184,8 @@ protected int processRow(String[] values, long rowNumber) throws Throwable {
revisionMap.put(ecrfRevision, ecrfVectors);
}
String label = "ecrf " + ecrfName + ", revision " + ecrfRevision
+ ": field section " + section + ", position " + position + ", field '" + ecrfFieldVO.getField().getNameL10nKey() + "'";
+ ": field section " + ecrfFieldVO.getSection() + ", position " + Long.toString(ecrfFieldVO.getPosition()) + ", field '" + ecrfFieldVO.getField().getNameL10nKey()
+ "'";
EcrfValidationTestVector v = new EcrfValidationTestVector();
v.setInputValue(getInputValue(values) != null ? getInputValue(values) : "");
v.setExportedValue(getExportedValue(values) != null ? getExportedValue(values) : "");
Expand All @@ -224,8 +203,8 @@ protected boolean testNotNullRowFields(String[] values, long rowNumber) {
if (CommonUtil.isEmptyString(getEcrfName(values))) {
return false;
}
if (CommonUtil.isEmptyString(getPosition(values))) {
jobOutput.println("row " + rowNumber + ": empty position");
if (CommonUtil.isEmptyString(getRef(values))) {
jobOutput.println("row " + rowNumber + ": empty ref");
return false;
}
return true;
Expand Down
Binary file modified core/src/test/resources/ecrfs.xls
Binary file not shown.

0 comments on commit 5762eca

Please sign in to comment.