1 package org.apache.maven.surefire.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Collections;
23 import java.util.Map;
24
25
26
27
28 public class CategorizedReportEntry
29 extends SimpleReportEntry
30 implements ReportEntry
31 {
32 private static final String GROUP_PREFIX = " (of ";
33
34 private static final String GROUP_SUFIX = ")";
35
36 private final String group;
37
38 public CategorizedReportEntry( String source, String name, String group )
39 {
40 this( source, name, group, null, null );
41 }
42
43 public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
44 Integer elapsed )
45 {
46 super( source, name, stackTraceWriter, elapsed );
47 this.group = group;
48 }
49
50 public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
51 Integer elapsed, String message )
52 {
53 this( source, name, group, stackTraceWriter, elapsed, message, Collections.<String, String>emptyMap() );
54 }
55
56 public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
57 Integer elapsed, String message, Map<String, String> systemProperties )
58 {
59 super( source, name, stackTraceWriter, elapsed, message, systemProperties );
60 this.group = group;
61 }
62
63 public static TestSetReportEntry reportEntry( String source, String name, String group,
64 StackTraceWriter stackTraceWriter, Integer elapsed, String message,
65 Map<String, String> systemProperties )
66 {
67 return group != null
68 ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed, message, systemProperties )
69 : new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message, systemProperties );
70 }
71
72 @Override
73 public String getGroup()
74 {
75 return group;
76 }
77
78 @Override
79 public String getNameWithGroup()
80 {
81 return isNameWithGroup() ? getName() + GROUP_PREFIX + getGroup() + GROUP_SUFIX : getName();
82 }
83
84 @Override
85 public boolean equals( Object o )
86 {
87 if ( this == o )
88 {
89 return true;
90 }
91 if ( o == null || getClass() != o.getClass() )
92 {
93 return false;
94 }
95 if ( !super.equals( o ) )
96 {
97 return false;
98 }
99
100 CategorizedReportEntry that = (CategorizedReportEntry) o;
101
102 return !( group != null ? !group.equals( that.group ) : that.group != null );
103
104 }
105
106 @Override
107 public int hashCode()
108 {
109 int result = super.hashCode();
110 result = 31 * result + ( group != null ? group.hashCode() : 0 );
111 return result;
112 }
113
114 private boolean isNameWithGroup()
115 {
116 return getGroup() != null && !getGroup().equals( getName() );
117 }
118 }