-
Notifications
You must be signed in to change notification settings - Fork 188
/
TestCsvReport.java
136 lines (112 loc) · 4.44 KB
/
TestCsvReport.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* Copyright (c) 2010-2019 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.report;
import java.io.IOException;
import java.util.List;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExportConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType;
import org.testng.annotations.Test;
/**
* @author skublik
*/
public class TestCsvReport extends BasicNewReportTest {
int expectedColumns;
int expectedRow;
@Override
public void test001CreateDashboardReportWithDefaultColumn() throws Exception {
setExpectedValueForDashboardReport();
super.test001CreateDashboardReportWithDefaultColumn();
}
@Override
public void test002CreateDashboardReportWithView() throws Exception {
setExpectedValueForDashboardReport();
super.test002CreateDashboardReportWithView();
}
@Override
public void test003CreateDashboardReportWithTripleView() throws Exception {
setExpectedValueForDashboardReport();
super.test003CreateDashboardReportWithTripleView();
}
@Override
public void test010CreateObjectCollectionReportWithDefaultColumn() throws Exception {
expectedColumns = 6;
expectedRow = 4;
super.test010CreateObjectCollectionReportWithDefaultColumn();
}
@Override
public void test011CreateObjectCollectionReportWithView() throws Exception {
expectedColumns = 2;
expectedRow = 2;
super.test011CreateObjectCollectionReportWithView();
}
@Override
public void test012CreateObjectCollectionReportWithDoubleView() throws Exception {
expectedColumns = 3;
expectedRow = 4;
super.test012CreateObjectCollectionReportWithDoubleView();
}
@Override
public void test013CreateAuditCollectionReportWithDefaultColumn() throws Exception {
expectedColumns = 8;
expectedRow = 46;
super.test013CreateAuditCollectionReportWithDefaultColumn();
}
@Override
public void test014CreateAuditCollectionReportWithView() throws Exception {
expectedColumns = 2;
expectedRow = 48;
super.test014CreateAuditCollectionReportWithView();
}
@Override
public void test015CreateAuditCollectionReportWithDoubleView() throws Exception {
expectedColumns = 3;
expectedRow = 50;
super.test015CreateAuditCollectionReportWithDoubleView();
}
@Override
public void test016CreateObjectCollectionReportWithFilter() throws Exception {
expectedColumns = 2;
expectedRow = 3;
super.test016CreateObjectCollectionReportWithFilter();
}
@Override
public void test017CreateObjectCollectionReportWithFilterAndBasicCollection() throws Exception {
expectedColumns = 2;
expectedRow = 2;
super.test017CreateObjectCollectionReportWithFilterAndBasicCollection();
}
private void setExpectedValueForDashboardReport() {
expectedColumns = 3;
expectedRow = 8;
}
@Override
protected ExportConfigurationType getExportConfiguration() {
ExportConfigurationType config = new ExportConfigurationType();
config.setType(ExportType.CSV);
return config;
}
protected List<String> basicCheckOutputFile(PrismObject<ReportType> report) throws IOException, SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
List<String> lines = super.basicCheckOutputFile(report);
if (lines.size() != expectedRow) {
fail("Unexpected count of rows of csv report. Expected: " + expectedRow + ", Actual: " + lines.size());
}
int actualColumns = getNumberOfColumns(lines);
if (actualColumns != expectedColumns) {
fail("Unexpected count of columns of csv report. Expected: " + expectedColumns + ", Actual: " + actualColumns);
}
return lines;
}
private int getNumberOfColumns(List<String> lines) {
if (lines.isEmpty()) {
throw new IllegalArgumentException("Couldn't find line of report");
}
return lines.get(0).split(";").length;
}
}