Skip to content

Commit 06f03a6

Browse files
author
Nico
committed
cambios nico comments
1 parent cb81bb3 commit 06f03a6

File tree

1 file changed

+28
-159
lines changed

1 file changed

+28
-159
lines changed

elections-ejb/src/test/java/net/lacnic/elections/domain/ElectionTest.java

Lines changed: 28 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import net.lacnic.ReflectTool;
1717

1818
public class ElectionTest extends TestCase {
19+
1920
/**
2021
* @return the suite of tests being tested
2122
*/
@@ -26,176 +27,44 @@ public static Test suite() {
2627
public void testElection() {
2728
AssertAnnotations.assertType(Election.class, Entity.class);
2829

29-
// fields
30+
// Individual Fields with Multiple Annotations
3031
AssertAnnotations.assertField(Election.class, "electionId", Id.class, GeneratedValue.class, SequenceGenerator.class, Column.class);
31-
AssertAnnotations.assertField(Election.class, "migrationId", Column.class);
3232
AssertAnnotations.assertField(Election.class, "category", Column.class, Enumerated.class);
33-
AssertAnnotations.assertField(Election.class, "migrated", Column.class);
34-
AssertAnnotations.assertField(Election.class, "startDate", Column.class);
35-
AssertAnnotations.assertField(Election.class, "endDate", Column.class);
36-
AssertAnnotations.assertField(Election.class, "creationDate", Column.class);
37-
AssertAnnotations.assertField(Election.class, "titleSpanish", Column.class);
38-
AssertAnnotations.assertField(Election.class, "titleEnglish", Column.class);
39-
AssertAnnotations.assertField(Election.class, "titlePortuguese", Column.class);
40-
AssertAnnotations.assertField(Election.class, "linkSpanish", Column.class);
41-
AssertAnnotations.assertField(Election.class, "linkEnglish", Column.class);
42-
AssertAnnotations.assertField(Election.class, "linkPortuguese", Column.class);
43-
AssertAnnotations.assertField(Election.class, "descriptionSpanish", Column.class);
44-
AssertAnnotations.assertField(Election.class, "descriptionEnglish", Column.class);
45-
AssertAnnotations.assertField(Election.class, "descriptionPortuguese", Column.class);
46-
AssertAnnotations.assertField(Election.class, "maxCandidates", Column.class);
47-
AssertAnnotations.assertField(Election.class, "votingLinkAvailable", Column.class);
48-
AssertAnnotations.assertField(Election.class, "resultLinkAvailable", Column.class);
49-
AssertAnnotations.assertField(Election.class, "auditorLinkAvailable", Column.class);
50-
AssertAnnotations.assertField(Election.class, "revisionRequest", Column.class);
51-
AssertAnnotations.assertField(Election.class, "onlySp", Column.class);
52-
AssertAnnotations.assertField(Election.class, "resultToken", Column.class);
53-
AssertAnnotations.assertField(Election.class, "defaultSender", Column.class);
54-
AssertAnnotations.assertField(Election.class, "electorsSet", Column.class);
55-
AssertAnnotations.assertField(Election.class, "candidatesSet", Column.class);
56-
AssertAnnotations.assertField(Election.class, "auditorsSet", Column.class);
57-
AssertAnnotations.assertField(Election.class, "randomOrderCandidates", Column.class);
58-
AssertAnnotations.assertField(Election.class, "diffUTC", Column.class);
59-
AssertAnnotations.assertField(Election.class, "candidates", OneToMany.class);
60-
AssertAnnotations.assertField(Election.class, "userVoters", OneToMany.class);
61-
AssertAnnotations.assertField(Election.class, "auditors", OneToMany.class);
62-
AssertAnnotations.assertField(Election.class, "electionTemplates", OneToMany.class);
63-
AssertAnnotations.assertField(Election.class, "votes", OneToMany.class);
64-
AssertAnnotations.assertField(Election.class, "email", OneToMany.class);
65-
AssertAnnotations.assertField(Election.class, "auxStartDate", Transient.class);
66-
AssertAnnotations.assertField(Election.class, "auxStartHour", Transient.class);
67-
AssertAnnotations.assertField(Election.class, "auxEndDate", Transient.class);
68-
AssertAnnotations.assertField(Election.class, "auxEndHour", Transient.class);
69-
AssertAnnotations.assertField(Election.class, "closed", Column.class);
70-
AssertAnnotations.assertField(Election.class, "closedDate", Column.class);
7133

72-
// metodos
73-
AssertAnnotations.assertMethod(Election.class, "getElectionId");
74-
AssertAnnotations.assertMethod(Election.class, "getStartDate");
75-
AssertAnnotations.assertMethod(Election.class, "getEndDate");
76-
AssertAnnotations.assertMethod(Election.class, "getMaxCandidates");
77-
AssertAnnotations.assertMethod(Election.class, "isVotingLinkAvailable");
78-
AssertAnnotations.assertMethod(Election.class, "getCandidates");
79-
AssertAnnotations.assertMethod(Election.class, "getCreationDate");
80-
AssertAnnotations.assertMethod(Election.class, "getUserVoters");
81-
AssertAnnotations.assertMethod(Election.class, "getVotes");
82-
AssertAnnotations.assertMethod(Election.class, "isResultLinkAvailable");
83-
AssertAnnotations.assertMethod(Election.class, "getTitleSpanish");
84-
AssertAnnotations.assertMethod(Election.class, "getTitleEnglish");
85-
AssertAnnotations.assertMethod(Election.class, "getTitlePortuguese");
86-
AssertAnnotations.assertMethod(Election.class, "getDescriptionSpanish");
87-
AssertAnnotations.assertMethod(Election.class, "getDescriptionEnglish");
88-
AssertAnnotations.assertMethod(Election.class, "getDescriptionPortuguese");
89-
AssertAnnotations.assertMethod(Election.class, "getResultToken");
90-
AssertAnnotations.assertMethod(Election.class, "getAuditors");
91-
AssertAnnotations.assertMethod(Election.class, "getLinkSpanish");
92-
AssertAnnotations.assertMethod(Election.class, "getLinkEnglish");
93-
AssertAnnotations.assertMethod(Election.class, "getLinkPortuguese");
94-
AssertAnnotations.assertMethod(Election.class, "getAuxStartDate");
95-
AssertAnnotations.assertMethod(Election.class, "getAuxStartHour");
96-
AssertAnnotations.assertMethod(Election.class, "getAuxEndHour");
97-
AssertAnnotations.assertMethod(Election.class, "getAuxEndHour");
98-
AssertAnnotations.assertMethod(Election.class, "isOnlySp");
99-
AssertAnnotations.assertMethod(Election.class, "isAuditorLinkAvailable");
100-
AssertAnnotations.assertMethod(Election.class, "isElectorsSet");
101-
AssertAnnotations.assertMethod(Election.class, "isCandidatesSet");
102-
AssertAnnotations.assertMethod(Election.class, "isAuditorsSet");
103-
AssertAnnotations.assertMethod(Election.class, "getElectionTemplates");
104-
AssertAnnotations.assertMethod(Election.class, "getDefaultSender");
105-
AssertAnnotations.assertMethod(Election.class, "getResultLink");
106-
AssertAnnotations.assertMethod(Election.class, "isRandomOrderCandidates");
107-
AssertAnnotations.assertMethod(Election.class, "getStartDateString");
108-
AssertAnnotations.assertMethod(Election.class, "getDiffUTC");
109-
AssertAnnotations.assertMethod(Election.class, "isRevisionRequest");
110-
AssertAnnotations.assertMethod(Election.class, "isFinished");
111-
AssertAnnotations.assertMethod(Election.class, "isStarted");
112-
AssertAnnotations.assertMethod(Election.class, "isEnabledToVote");
113-
AssertAnnotations.assertMethod(Election.class, "isMigrated");
114-
AssertAnnotations.assertMethod(Election.class, "getCategory");
115-
AssertAnnotations.assertMethod(Election.class, "isClosed");
116-
AssertAnnotations.assertMethod(Election.class, "getClosedDate");
34+
// Grouped Fields with Single Annotation
35+
String[] columnFields = { "migrationId", "migrated", "startDate", "endDate", "creationDate", "titleSpanish", "titleEnglish", "titlePortuguese", "linkSpanish", "linkEnglish", "linkPortuguese", "descriptionSpanish", "descriptionEnglish", "descriptionPortuguese", "maxCandidates", "votingLinkAvailable", "resultLinkAvailable", "auditorLinkAvailable", "revisionRequest", "onlySp", "resultToken", "defaultSender", "electorsSet", "candidatesSet", "auditorsSet", "randomOrderCandidates", "diffUTC", "closed", "closedDate" };
36+
for (String field : columnFields) {
37+
AssertAnnotations.assertField(Election.class, field, Column.class);
38+
}
39+
40+
String[] transientFields = { "auxStartDate", "auxStartHour", "auxEndDate", "auxEndHour" };
41+
for (String field : transientFields) {
42+
AssertAnnotations.assertField(Election.class, field, Transient.class);
43+
}
44+
45+
String[] oneToManyFields = { "candidates", "userVoters", "auditors", "electionTemplates", "votes", "email" };
46+
for (String field : oneToManyFields) {
47+
AssertAnnotations.assertField(Election.class, field, OneToMany.class);
48+
}
11749

118-
// class annotations
50+
// Grouped Methods
51+
String[] methods = { "getElectionId", "getStartDate", "getEndDate", "getMaxCandidates", "isVotingLinkAvailable", "getCandidates", "getCreationDate", "getUserVoters", "getVotes", "isResultLinkAvailable", "getTitleSpanish", "getTitleEnglish", "getTitlePortuguese", "getDescriptionSpanish", "getDescriptionEnglish", "getDescriptionPortuguese", "getResultToken", "getAuditors", "getLinkSpanish", "getLinkEnglish", "getLinkPortuguese", "getAuxStartDate", "getAuxStartHour", "getAuxEndDate", "getAuxEndHour", "isOnlySp", "isAuditorLinkAvailable", "isElectorsSet", "isCandidatesSet", "isAuditorsSet", "getElectionTemplates", "getDefaultSender", "getResultLink", "isRandomOrderCandidates", "getStartDateString", "getDiffUTC", "isRevisionRequest", "isFinished", "isStarted", "isEnabledToVote", "isMigrated", "getCategory", "isClosed", "getClosedDate" };
52+
for (String method : methods) {
53+
AssertAnnotations.assertMethod(Election.class, method);
54+
}
55+
56+
// Class Annotations
11957
Entity a = ReflectTool.getClassAnnotation(Election.class, Entity.class);
12058
assertEquals("", a.name());
12159

122-
Column c;
123-
OneToMany oa;
124-
c = ReflectTool.getFieldAnnotation(Election.class, "electionId", Column.class);
60+
// Specific Annotations
61+
Column c = ReflectTool.getFieldAnnotation(Election.class, "electionId", Column.class);
12562
assertEquals("election_id", c.name());
12663
c = ReflectTool.getFieldAnnotation(Election.class, "migrationId", Column.class);
12764
assertEquals("migration_id", c.name());
128-
c = ReflectTool.getFieldAnnotation(Election.class, "category", Column.class);
129-
assertEquals("", c.name());
130-
c = ReflectTool.getFieldAnnotation(Election.class, "migrated", Column.class);
131-
assertEquals("", c.name());
132-
c = ReflectTool.getFieldAnnotation(Election.class, "startDate", Column.class);
133-
assertEquals("", c.name());
134-
c = ReflectTool.getFieldAnnotation(Election.class, "endDate", Column.class);
135-
assertEquals("", c.name());
136-
c = ReflectTool.getFieldAnnotation(Election.class, "creationDate", Column.class);
137-
assertEquals("", c.name());
138-
c = ReflectTool.getFieldAnnotation(Election.class, "titleSpanish", Column.class);
139-
assertEquals("", c.name());
140-
c = ReflectTool.getFieldAnnotation(Election.class, "titleEnglish", Column.class);
141-
assertEquals("", c.name());
142-
c = ReflectTool.getFieldAnnotation(Election.class, "titlePortuguese", Column.class);
143-
assertEquals("", c.name());
144-
c = ReflectTool.getFieldAnnotation(Election.class, "linkSpanish", Column.class);
145-
assertEquals("", c.name());
146-
c = ReflectTool.getFieldAnnotation(Election.class, "linkEnglish", Column.class);
147-
assertEquals("", c.name());
148-
c = ReflectTool.getFieldAnnotation(Election.class, "linkPortuguese", Column.class);
149-
assertEquals("", c.name());
150-
c = ReflectTool.getFieldAnnotation(Election.class, "descriptionSpanish", Column.class);
151-
assertEquals("", c.name());
152-
c = ReflectTool.getFieldAnnotation(Election.class, "descriptionEnglish", Column.class);
153-
assertEquals("", c.name());
154-
c = ReflectTool.getFieldAnnotation(Election.class, "descriptionPortuguese", Column.class);
155-
assertEquals("", c.name());
156-
c = ReflectTool.getFieldAnnotation(Election.class, "maxCandidates", Column.class);
157-
assertEquals("", c.name());
158-
c = ReflectTool.getFieldAnnotation(Election.class, "votingLinkAvailable", Column.class);
159-
assertEquals("", c.name());
160-
c = ReflectTool.getFieldAnnotation(Election.class, "resultLinkAvailable", Column.class);
161-
assertEquals("", c.name());
162-
c = ReflectTool.getFieldAnnotation(Election.class, "auditorLinkAvailable", Column.class);
163-
assertEquals("", c.name());
164-
c = ReflectTool.getFieldAnnotation(Election.class, "revisionRequest", Column.class);
165-
assertEquals("", c.name());
166-
c = ReflectTool.getFieldAnnotation(Election.class, "onlySp", Column.class);
167-
assertEquals("", c.name());
168-
c = ReflectTool.getFieldAnnotation(Election.class, "resultToken", Column.class);
169-
assertEquals("", c.name());
170-
c = ReflectTool.getFieldAnnotation(Election.class, "defaultSender", Column.class);
171-
assertEquals("", c.name());
172-
c = ReflectTool.getFieldAnnotation(Election.class, "electorsSet", Column.class);
173-
assertEquals("", c.name());
174-
c = ReflectTool.getFieldAnnotation(Election.class, "candidatesSet", Column.class);
175-
assertEquals("", c.name());
176-
c = ReflectTool.getFieldAnnotation(Election.class, "auditorsSet", Column.class);
177-
assertEquals("", c.name());
178-
c = ReflectTool.getFieldAnnotation(Election.class, "randomOrderCandidates", Column.class);
179-
assertEquals("", c.name());
180-
c = ReflectTool.getFieldAnnotation(Election.class, "diffUTC", Column.class);
181-
assertEquals("", c.name());
182-
oa = ReflectTool.getFieldAnnotation(Election.class, "candidates", OneToMany.class);
65+
OneToMany oa = ReflectTool.getFieldAnnotation(Election.class, "candidates", OneToMany.class);
18366
assertEquals("election", oa.mappedBy());
18467
oa = ReflectTool.getFieldAnnotation(Election.class, "auditors", OneToMany.class);
18568
assertEquals("election", oa.mappedBy());
186-
oa = ReflectTool.getFieldAnnotation(Election.class, "userVoters", OneToMany.class);
187-
assertEquals("election", oa.mappedBy());
188-
oa = ReflectTool.getFieldAnnotation(Election.class, "electionTemplates", OneToMany.class);
189-
assertEquals("election", oa.mappedBy());
190-
oa = ReflectTool.getFieldAnnotation(Election.class, "votes", OneToMany.class);
191-
assertEquals("election", oa.mappedBy());
192-
oa = ReflectTool.getFieldAnnotation(Election.class, "email", OneToMany.class);
193-
assertEquals("election", oa.mappedBy());
194-
c = ReflectTool.getFieldAnnotation(Election.class, "closed", Column.class);
195-
assertEquals("", c.name());
196-
c = ReflectTool.getFieldAnnotation(Election.class, "closedDate", Column.class);
197-
assertEquals("", c.name());
198-
19969
}
200-
201-
}
70+
}

0 commit comments

Comments
 (0)