public ParameterWithValueDeclaration getReturnResult() { ParameterWithValueDeclaration returnResult = null; Object result = tto.getResult(); if (result != null) { returnResult = new ParameterWithValueDeclaration("return", result); } return returnResult; }
protected Object getSimpleValue(Object value) { if (value == null) { return null; } if (value instanceof ParameterWithValueDeclaration) { ParameterWithValueDeclaration parameter = (ParameterWithValueDeclaration) value; Object simpleValue = parameter.getValue(); // Return key field for complex objects IOpenField keyField = parameter.getKeyField(); if (keyField != null) { // If key can't be found, return the object itself Object key = ExportUtils.fieldValue(simpleValue, keyField); simpleValue = key == null ? simpleValue : key; } return getSimpleValue(simpleValue); } return value; } }
public ParameterDeclarationTreeNode[] initArgumentTreeNodes() { ParameterWithValueDeclaration[] args = getArguments(); ParameterDeclarationTreeNode[] argTreeNodes = new ParameterDeclarationTreeNode[args.length]; for (int i = 0; i < args.length; i++) { ParameterRenderConfig config = new ParameterRenderConfig.Builder(args[i].getType(), args[i].getValue()) .fieldNameInParent(args[i].getName()) .build(); argTreeNodes[i] = ParameterTreeBuilder.createNode(config); } return argTreeNodes; }
public boolean isHtmlTable(Object value) { if (value instanceof ParameterWithValueDeclaration) { Object singlValue = value; if (Utils.isCollection(((ParameterWithValueDeclaration) value).getType())) { Iterator<Object> iterator = ((ParameterWithValueDeclaration) value).getType().getAggregateInfo() .getIterator(((ParameterWithValueDeclaration) value).getValue()); if (iterator.hasNext()) { singlValue = iterator.next(); } } return checkTableObjectType(singlValue); } return false; }
public boolean isComplexResult(Object objTestUnit) { Object actualValue = getActualResultInternal(objTestUnit); ParameterWithValueDeclaration param = new ParameterWithValueDeclaration("actual", actualValue ); return !param.getType().isSimple() && !isResultThrowable(objTestUnit); }
public TreeNode getTree(String requestId, ParameterWithValueDeclaration param, boolean hasExplainLinks) { TreeNodeImpl root = new TreeNodeImpl(); if (param != null) { ParameterRenderConfig config = new ParameterRenderConfig.Builder(param.getType(), param.getValue()) .keyField(param.getKeyField()) .hasExplainLinks(hasExplainLinks) .requestId(requestId) .build(); ParameterDeclarationTreeNode treeNode = createNode(config); root.addChild(param.getName(), treeNode); } return root; }
public String getRoot(ParameterWithValueDeclaration param) { if (param == null) { return "null"; } Object value = param.getValue(); if (value != null) { IOpenClass fieldType = param.getType(); if (Utils.isCollection(fieldType)) { boolean empty = !fieldType.getAggregateInfo().getIterator(value).hasNext(); return Utils.displayNameForCollection(fieldType, empty); } else if (!fieldType.isSimple()) { ParameterRenderConfig config = new ParameterRenderConfig.Builder(fieldType, value) .keyField(param.getKeyField()) .build(); return createComplexBeanNode(config).getDisplayedValue(); } } return "null"; }
public Object[] getArguments(OpenLArgumentsCloner cloner) { Object[] args = new Object[executionParams.length]; for (int i = 0; i < args.length; i++) { Object value = executionParams[i].getValue(); ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { if (value != null) { Thread.currentThread().setContextClassLoader(value.getClass().getClassLoader()); } try { args[i] = cloner.deepClone(value); } catch (RuntimeException e) { Log.error("Failed to clone an argument \"{0}\". Original argument will be used.", executionParams[i].getName()); args[i] = value; } } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); } } return args; }
private List<Object> valuesForAllCases(TestDescription[] testDescriptions, int paramNum) { List<Object> values = new ArrayList<>(); for (TestDescription description : testDescriptions) { ParameterWithValueDeclaration[] executionParams = description.getExecutionParams(); if (executionParams.length > 0) { values.add(executionParams[paramNum].getValue()); } else { values.add(null); } } return values; }
public String[] getParametersNames() { String[] names = new String[executionParams.length]; for (int i = 0; i < executionParams.length; i++) { names[i] = executionParams[i].getName(); } return names; }
private boolean isHasPK(ParameterWithValueDeclaration param) { return param.getKeyField() instanceof PrimaryKeyField; }
private List<List<FieldDescriptor>> getAllNonEmptyFields(TestDescription[] descriptions) { TestDescription description = descriptions[0]; ParameterWithValueDeclaration[] executionParams = description.getExecutionParams(); List<List<FieldDescriptor>> result = new ArrayList<>(executionParams.length); for (int i = 0; i < executionParams.length; i++) { ParameterWithValueDeclaration param = executionParams[i]; result.add(FieldDescriptor.nonEmptyFields(param.getType(), valuesForAllCases(descriptions, i))); } return result; }
public ParameterWithValueDeclaration(String paramName, Object value) { super(getParamType(value), paramName); this.value = value; }
public TreeNode getTree(String requestId, ParameterWithValueDeclaration param, boolean hasExplainLinks) { TreeNodeImpl root = new TreeNodeImpl(); if (param != null) { ParameterRenderConfig config = new ParameterRenderConfig.Builder(param.getType(), param.getValue()) .keyField(param.getKeyField()) .hasExplainLinks(hasExplainLinks) .requestId(requestId) .build(); ParameterDeclarationTreeNode treeNode = createNode(config); root.addChild(param.getName(), treeNode); } return root; }
public String getRoot(ParameterWithValueDeclaration param) { if (param == null) { return "null"; } Object value = param.getValue(); if (value != null) { IOpenClass fieldType = param.getType(); if (Utils.isCollection(fieldType)) { boolean empty = !fieldType.getAggregateInfo().getIterator(value).hasNext(); return Utils.displayNameForCollection(fieldType, empty); } else if (!fieldType.isSimple()) { ParameterRenderConfig config = new ParameterRenderConfig.Builder(fieldType, value) .keyField(param.getKeyField()) .build(); return createComplexBeanNode(config).getDisplayedValue(); } } return "null"; }
public boolean isHtmlTable(Object value) { if (value instanceof ParameterWithValueDeclaration) { Object singlValue = value; if (Utils.isCollection(((ParameterWithValueDeclaration) value).getType())) { Iterator<Object> iterator = ((ParameterWithValueDeclaration) value).getType().getAggregateInfo() .getIterator(((ParameterWithValueDeclaration) value).getValue()); if (iterator.hasNext()) { singlValue = iterator.next(); } } return checkTableObjectType(singlValue); } return false; }
public boolean isComplexResult(Object objTestUnit) { Object actualValue = getActualResultInternal(objTestUnit); ParameterWithValueDeclaration param = new ParameterWithValueDeclaration("actual", actualValue ); return !param.getType().isSimple() && !isResultThrowable(objTestUnit); }
private int getMaxHeight(TestDescription description, List<List<FieldDescriptor>> nonEmptyFields) { int maxHeight = 1; ParameterWithValueDeclaration[] executionParams = description.getExecutionParams(); for (int i = 0; i < executionParams.length; i++) { ParameterWithValueDeclaration param = executionParams[i]; List<FieldDescriptor> fields = nonEmptyFields.get(i); int rowHeight = getRowHeight(param.getValue(), fields); if (rowHeight > maxHeight) { maxHeight = rowHeight; } } return maxHeight; }
private Cursor writeHeaderForFields(SXSSFSheet sheet, Cursor start, TestUnitsResults test, List<List<FieldDescriptor>> nonEmptyFields) { TreeSet<WriteTask> tasks = new TreeSet<>(); int rowNum = start.getRowNum(); int colNum = start.getColNum(); tasks.add(new WriteTask(new Cursor(rowNum, colNum++), "ID", styles.header)); TestSuite testSuite = test.getTestSuite(); ParameterWithValueDeclaration[] params = testSuite.getTest(0).getExecutionParams(); for (int i = 0; i < params.length; i++) { ParameterWithValueDeclaration param = params[i]; boolean hasPK = isHasPK(param); List<FieldDescriptor> fields = nonEmptyFields.get(i); if (fields == null || fields.isEmpty()) { tasks.add(new WriteTask(new Cursor(rowNum, colNum++), param.getName(), styles.header)); continue; } String prefix = param.getName() + "."; if (hasPK) { tasks.add(new WriteTask(new Cursor(rowNum, colNum++), prefix + "_PK_", styles.header)); } colNum = addHeaderTasks(tasks, new Cursor(rowNum, colNum), fields, prefix); } return performWrite(sheet, start, tasks, getLastColumn(test, nonEmptyFields)); }
public ParameterDeclarationTreeNode[] initArgumentTreeNodes() { ParameterWithValueDeclaration[] args = getArguments(); ParameterDeclarationTreeNode[] argTreeNodes = new ParameterDeclarationTreeNode[args.length]; for (int i = 0; i < args.length; i++) { ParameterRenderConfig config = new ParameterRenderConfig.Builder(args[i].getType(), args[i].getValue()) .fieldNameInParent(args[i].getName()) .build(); argTreeNodes[i] = ParameterTreeBuilder.createNode(config); } return argTreeNodes; }