Revision 0844524a
Added by Andreas Kohlbecker about 6 years ago
src/test/java/eu/etaxonomy/cdm/service/SpecimenTypeDesignationWorkingSetServiceImplTest.java | ||
---|---|---|
11 | 11 |
import java.io.FileNotFoundException; |
12 | 12 |
import java.net.URI; |
13 | 13 |
import java.net.URISyntaxException; |
14 |
import java.util.UUID; |
|
14 | 15 |
|
15 | 16 |
import org.junit.Assert; |
16 | 17 |
import org.junit.BeforeClass; |
... | ... | |
69 | 70 |
// Logger.getLogger("org.dbunit").setLevel(Level.DEBUG); |
70 | 71 |
} |
71 | 72 |
|
72 |
int registrationId = 5000;
|
|
73 |
UUID registrationUuid = UUID.fromString("c8bb4e70-ca85-43c3-ae81-c90a2b41a93f"); // 5000;
|
|
73 | 74 |
|
74 |
private Integer publicationId = 5000;
|
|
75 |
private UUID publicationUuid = UUID.fromString("45804c65-7df9-42fd-b43a-818a8958c264"); // 5000;
|
|
75 | 76 |
|
76 |
private Integer typifiedNameId = 5000; |
|
77 |
private UUID typifiedNameUuid = UUID.fromString("47d9263e-b32a-42af-98ea-5528f154384f"); // 5000; |
|
78 |
|
|
79 |
UUID fieldUnitUuid = UUID.fromString("22be718a-6f21-4b74-aae3-bb7d7d659e1c"); // 5001 |
|
77 | 80 |
|
78 | 81 |
private final String[] includeTableNames_create = new String[]{"TAXONNAME", "REFERENCE", "AGENTBASE", "HOMOTYPICALGROUP", "REGISTRATION", |
79 | 82 |
"HIBERNATE_SEQUENCES"}; |
... | ... | |
99 | 102 |
// "REPRESENTATION", "REPRESENTATION_AUD", "HIBERNATE_SEQUENCES"}, |
100 | 103 |
// "RegistrationTerms"); |
101 | 104 |
|
102 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.create(registrationId, publicationId, typifiedNameId);
|
|
105 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.create(registrationUuid, publicationUuid, typifiedNameUuid);
|
|
103 | 106 |
|
104 | 107 |
Assert.assertNotNull(workingset.getOwner()); |
105 | 108 |
Assert.assertEquals(Registration.class, workingset.getOwner().getClass()); |
106 | 109 |
|
107 | 110 |
workingset.getFieldUnit().setFieldNotes("FieldNotes"); |
108 |
int baseEntityID = workingset.getFieldUnit().getId(); |
|
111 |
// int baseEntityID = workingset.getFieldUnit().getId();
|
|
109 | 112 |
workingset.getFieldUnit().setFieldNumber("FieldNumber"); |
110 | 113 |
workingset.getFieldUnit().getGatheringEvent().setLocality(LanguageString.NewInstance("Somewhere", Language.ENGLISH())); |
111 | 114 |
|
... | ... | |
124 | 127 |
|
125 | 128 |
printDataSetWithNull(System.err, new String[]{"TYPEDESIGNATIONBASE", "SPECIMENOROBSERVATIONBASE"}); |
126 | 129 |
|
127 |
TypedEntityReference<FieldUnit> baseEntityRef = new TypedEntityReference<FieldUnit>(FieldUnit.class, baseEntity.getId(), baseEntity.getTitleCache());
|
|
130 |
TypedEntityReference<FieldUnit> baseEntityRef = new TypedEntityReference<FieldUnit>(FieldUnit.class, baseEntity.getUuid(), baseEntity.getTitleCache());
|
|
128 | 131 |
|
129 |
workingset = service.loadDtoByIds(registrationId, baseEntityRef);
|
|
132 |
workingset = service.load(registrationUuid, baseEntityRef);
|
|
130 | 133 |
|
131 | 134 |
Assert.assertNotNull(specimenTypeDesignationDTO.asSpecimenTypeDesignation().getTypeSpecimen()); |
132 | 135 |
Assert.assertEquals(MediaSpecimen.class, specimenTypeDesignationDTO.asSpecimenTypeDesignation().getTypeSpecimen().getClass()); |
... | ... | |
143 | 146 |
|
144 | 147 |
service.save(workingset); |
145 | 148 |
|
146 |
workingset = service.loadDtoByIds(registrationId, baseEntityRef);
|
|
149 |
workingset = service.load(registrationUuid, baseEntityRef);
|
|
147 | 150 |
Assert.assertTrue(workingset.getSpecimenTypeDesignationDTOs().size() == 2); |
148 | 151 |
|
149 | 152 |
|
... | ... | |
174 | 177 |
public void test03_deleteTypeDesignationTest() { |
175 | 178 |
|
176 | 179 |
// FieldUnit" ID="5001 |
177 |
TypedEntityReference<FieldUnit> baseEntityRef = new TypedEntityReference<FieldUnit>(FieldUnit.class, 5001, "Somewhere, FieldNumber.");
|
|
178 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.loadDtoByIds(registrationId, baseEntityRef);
|
|
180 |
TypedEntityReference<FieldUnit> baseEntityRef = new TypedEntityReference<FieldUnit>(FieldUnit.class, fieldUnitUuid, "Somewhere, FieldNumber.");
|
|
181 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.load(registrationUuid, baseEntityRef);
|
|
179 | 182 |
Assert.assertTrue(workingset.getSpecimenTypeDesignationDTOs().size() == 2); |
180 | 183 |
|
181 | 184 |
SpecimenTypeDesignationDTO deleteDTO = null; |
... | ... | |
191 | 194 |
|
192 | 195 |
// printDataSetWithNull(System.err, includeTableNames_delete); |
193 | 196 |
|
194 |
workingset = service.loadDtoByIds(registrationId, baseEntityRef);
|
|
197 |
workingset = service.load(registrationUuid, baseEntityRef);
|
|
195 | 198 |
Registration reg = workingset.getOwner(); |
196 | 199 |
Assert.assertEquals(1, workingset.getSpecimenTypeDesignationDTOs().size()); |
197 | 200 |
reg = workingset.getOwner(); |
... | ... | |
204 | 207 |
|
205 | 208 |
// printDataSetWithNull(System.err, includeTableNames_delete); |
206 | 209 |
|
207 |
TypedEntityReference<FieldUnit> baseEntityRef = new TypedEntityReference<FieldUnit>(FieldUnit.class, 5001, null);
|
|
210 |
TypedEntityReference<FieldUnit> baseEntityRef = new TypedEntityReference<FieldUnit>(FieldUnit.class, fieldUnitUuid, null);
|
|
208 | 211 |
|
209 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.loadDtoByIds(registrationId, baseEntityRef);
|
|
212 |
SpecimenTypeDesignationWorkingSetDTO<Registration> workingset = service.load(registrationUuid, baseEntityRef);
|
|
210 | 213 |
Assert.assertNotNull(workingset.getOwner()); |
211 | 214 |
Assert.assertEquals(2, workingset.getSpecimenTypeDesignationDTOs().size()); |
212 | 215 |
service.delete(workingset, true); |
... | ... | |
241 | 244 |
|
242 | 245 |
Team team = Team.NewTitledInstance("Novis, Braidwood & Kilroy", "Novis, Braidwood & Kilroy"); |
243 | 246 |
Reference nomRef = ReferenceFactory.newArticle(); |
247 |
nomRef.setUuid(publicationUuid); |
|
244 | 248 |
nomRef = cdmRepository.getReferenceService().save(nomRef); |
245 |
publicationId = nomRef.getId(); |
|
246 | 249 |
|
247 | 250 |
nomRef.setAuthorship(team); |
248 | 251 |
nomRef.setTitle("P.M. Novis, J. Braidwood & C. Kilroy, Small diatoms (Bacillariophyta) in cultures from the Styx River, New Zealand, including descriptions of three new species in Phytotaxa 64"); |
249 | 252 |
TaxonName name = TaxonName.NewInstance(NomenclaturalCode.ICNAFP, Rank.SPECIES(), "Planothidium", null, "victori", null, null, nomRef, "11-45", null); |
253 |
name.setUuid(typifiedNameUuid); |
|
250 | 254 |
name = cdmRepository.getNameService().save(name); |
251 |
typifiedNameId = name.getId(); |
|
252 | 255 |
|
253 | 256 |
Registration reg = Registration.NewInstance(); |
254 | 257 |
reg.setName(name); |
258 |
reg.setUuid(registrationUuid); |
|
255 | 259 |
reg = cdmRepository.getRegistrationService().save(reg); |
256 |
registrationId = reg.getId(); |
|
257 | 260 |
|
258 | 261 |
|
259 | 262 |
//printDataSetWithNull(System.err, includeTableNames_create); |
Also available in: Unified diff
switching vom id based to uuid based ui navigation and entity references