Project

General

Profile

Revision 03384234

ID03384234cbfe3e7f3f199f59c5a6155e90e2a415
Parent 3787f4dc
Child 560db24d

Added by Andreas Müller 2 months ago

cleanup

View differences:

cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/taxonGraph/TaxonGraphHibernateListenerTest.java
73 73
    protected static UUID uuid_n_euglenophyceae = UUID.fromString("9928147d-4499-4ce9-bcf3-e4eaa13e509e");
74 74
    protected static UUID uuid_n_euglena = UUID.fromString("ab59d853-dd4f-4f80-bd7b-cf53bfd42d39");
75 75
    protected static UUID uuid_n_trachelomonas = UUID.fromString("5e3d015c-0a5c-4975-a3b0-334b4b47ff79");
76
    protected static UUID uuid_n_trachelomonas_a  = UUID.fromString("a798721a-e305-420d-aec1-e915ad1971e4");
77
    protected static UUID uuid_n_trachelomonas_o  = UUID.fromString("a2e7eeff-b844-4b3d-ab75-2a113b44573e");
78
    protected static UUID uuid_n_trachelomonas_o_var_d  = UUID.fromString("d8a0e3ad-2a4d-45ed-b874-f96616015f91");
79
    protected static UUID uuid_n_trachelomonas_s  = UUID.fromString("5b90bd58-7f76-45c4-9966-7f65e7bf0bb0");
76
    protected static UUID uuid_n_trachelomonas_a = UUID.fromString("a798721a-e305-420d-aec1-e915ad1971e4");
77
    protected static UUID uuid_n_trachelomonas_o = UUID.fromString("a2e7eeff-b844-4b3d-ab75-2a113b44573e");
78
    protected static UUID uuid_n_trachelomonas_o_var_d = UUID.fromString("d8a0e3ad-2a4d-45ed-b874-f96616015f91");
79
    protected static UUID uuid_n_trachelomonas_s = UUID.fromString("5b90bd58-7f76-45c4-9966-7f65e7bf0bb0");
80 80
    protected static UUID uuid_n_trachelomonas_s_var_a = UUID.fromString("192ad8a1-55ca-4379-87a1-3bbd04e8b880");
81 81
    protected static UUID uuid_n_trachelomonas_r_s = UUID.fromString("2d6e68bf-aba7-433d-8325-ea15f3e567f4");
82 82
    protected static UUID uuid_n_phacus_s = UUID.fromString("d59b8715-1b98-4da4-a42d-efcbe85b323c");
......
84 84
    protected static UUID uuid_t_euglenophyceae = UUID.fromString("4ea17d7a-17a3-41f0-8de6-e924494ecbae");
85 85
    protected static UUID uuid_t_euglena = UUID.fromString("1c69afd4-ae58-4913-8706-5c89729d38f4");
86 86
    protected static UUID uuid_t_trachelomonas = UUID.fromString("52b9a8e0-9133-4ee0-ba9f-84ca6e28d033");
87
    protected static UUID uuid_t_trachelomonas_a  = UUID.fromString("04443b64-f2e5-48c5-9069-9354f43ded9f");
88
    protected static UUID uuid_t_trachelomonas_o  = UUID.fromString("bdf75350-8361-4e33-a614-a4214cc3e90a");
89
    protected static UUID uuid_t_trachelomonas_o_var_d  = UUID.fromString("f54ad8cf-fe87-499d-826a-2c5a71551fcf");
90
    protected static UUID uuid_t_trachelomonas_s  = UUID.fromString("5dce8a09-c809-4027-a9ce-b70901e7b820");
87
    protected static UUID uuid_t_trachelomonas_a = UUID.fromString("04443b64-f2e5-48c5-9069-9354f43ded9f");
88
    protected static UUID uuid_t_trachelomonas_o = UUID.fromString("bdf75350-8361-4e33-a614-a4214cc3e90a");
89
    protected static UUID uuid_t_trachelomonas_o_var_d = UUID.fromString("f54ad8cf-fe87-499d-826a-2c5a71551fcf");
90
    protected static UUID uuid_t_trachelomonas_s = UUID.fromString("5dce8a09-c809-4027-a9ce-b70901e7b820");
91 91
    protected static UUID uuid_t_trachelomonas_s_var_a = UUID.fromString("3f14c528-e191-4a6f-b2a9-36c9a3fc7eee");
92 92

  
93 93
    private static TaxonGraphHibernateListener taxonGraphHibernateListener = new TaxonGraphHibernateListener();
......
95 95
    @Before
96 96
    public void registerListener() throws NoSuchMethodException, SecurityException {
97 97

  
98
        if(!TaxonGraphHibernateListenerTest.isRegistered){
99
            EventListenerRegistry listenerRegistry = ((SessionFactoryImpl) sessionFactory).getServiceRegistry().getService(EventListenerRegistry.class);
98
        if (!TaxonGraphHibernateListenerTest.isRegistered) {
99
            EventListenerRegistry listenerRegistry = ((SessionFactoryImpl) sessionFactory).getServiceRegistry()
100
                    .getService(EventListenerRegistry.class);
100 101
            listenerRegistry.appendListeners(EventType.POST_UPDATE, taxonGraphHibernateListener);
101 102
            listenerRegistry.appendListeners(EventType.POST_INSERT, taxonGraphHibernateListener);
102 103
            TaxonGraphHibernateListenerTest.isRegistered = true;
103 104
        }
104 105
        //
105
        taxonGraphHibernateListener.registerProcessClass(TaxonGraphBeforeTransactionCompleteProcess.class, new Object[]{new RunAsAdmin(runAsAuthenticationProvider)}, new Class[]{IRunAs.class});
106
        taxonGraphHibernateListener.registerProcessClass(TaxonGraphBeforeTransactionCompleteProcess.class,
107
                new Object[] { new RunAsAdmin(runAsAuthenticationProvider) }, new Class[] { IRunAs.class });
106 108
    }
107 109

  
108 110
    @After
......
117 119
    }
118 120

  
119 121
    @Test
120
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonGraphTest.xml")
121
    public void testNewTaxonName() throws TaxonGraphException{
122
    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "TaxonGraphTest.xml")
123
    public void testNewTaxonName() throws TaxonGraphException {
122 124

  
123
        try{
125
        try {
124 126
            setUuidPref();
125 127

  
126 128
            Reference refX = ReferenceFactory.newBook();
127 129
            refX.setTitleCache("Ref-X", true);
128 130

  
129
            TaxonName n_t_argentinensis = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES(), "Trachelomonas", null, "argentinensis", null, null, refX, null, null);
131
            TaxonName n_t_argentinensis = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES(), "Trachelomonas", null,
132
                    "argentinensis", null, null, refX, null, null);
130 133
            n_t_argentinensis = nameDao.save(n_t_argentinensis);
131 134
            commitAndStartNewTransaction();
132 135

  
......
143 146
    }
144 147

  
145 148
    @Test
146
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonGraphTest.xml")
147
    public void testNewGenusName() throws TaxonGraphException{
149
    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "TaxonGraphTest.xml")
150
    public void testNewGenusName() throws TaxonGraphException {
148 151

  
149
        try{
152
        try {
150 153
            setUuidPref();
151 154

  
152 155
            Reference refX = ReferenceFactory.newBook();
153 156
            refX.setTitleCache("Ref-X", true);
154 157

  
155
            TaxonName n_phacus = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS(), "Phacus", null, null, null, null, refX, null, null);
158
            TaxonName n_phacus = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS(), "Phacus", null, null, null, null,
159
                    refX, null, null);
156 160
            nameDao.save(n_phacus);
157 161
            commitAndStartNewTransaction();
158 162

  
......
186 190

  
187 191
            // printDataSet(System.err,"TaxonRelationship");
188 192

  
189
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(nameDao.load(uuid_n_trachelomonas_a), nameDao.load(uuid_n_trachelomonas), true);
193
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(nameDao.load(uuid_n_trachelomonas_a),
194
                    nameDao.load(uuid_n_trachelomonas), true);
190 195
            Assert.assertEquals(1, edges.size());
191 196
            Assert.assertEquals(refX.getUuid(), edges.get(0).getCitationUuid());
192 197
        } finally {
......
195 200
    }
196 201

  
197 202
    @Test
198
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonGraphTest.xml")
199
    public void testChangeRank() throws TaxonGraphException{
203
    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "TaxonGraphTest.xml")
204
    public void testChangeRank() throws TaxonGraphException {
200 205

  
201 206
        try {
202 207
            setUuidPref();
203 208

  
204 209
            TaxonName n_trachelomonas_o_var_d = nameDao.load(uuid_n_trachelomonas_o_var_d);
205 210

  
206
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(n_trachelomonas_o_var_d, nameDao.load(uuid_n_trachelomonas), true);
207
            Assert.assertEquals("One edge from 'Trachelomonas oviformis var. duplex' to 'Trachelomonas' expected", 1, edges.size());
211
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(n_trachelomonas_o_var_d,
212
                    nameDao.load(uuid_n_trachelomonas), true);
213
            Assert.assertEquals("One edge from 'Trachelomonas oviformis var. duplex' to 'Trachelomonas' expected", 1,
214
                    edges.size());
208 215

  
209 216
            n_trachelomonas_o_var_d.setRank(Rank.SPECIES());
210 217
            nameDao.saveOrUpdate(n_trachelomonas_o_var_d);
......
222 229
    }
223 230

  
224 231
    @Test
225
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonGraphTest.xml")
226
    public void testChangeGenus() throws TaxonGraphException{
232
    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "TaxonGraphTest.xml")
233
    public void testChangeGenus() throws TaxonGraphException {
227 234

  
228 235
        try {
229 236
            setUuidPref();
230 237

  
231 238
            TaxonName n_trachelomonas_o_var_d = nameDao.load(uuid_n_trachelomonas_o_var_d);
232 239

  
233
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(n_trachelomonas_o_var_d, nameDao.load(uuid_n_trachelomonas), true);
234
            Assert.assertEquals("One edge from 'Trachelomonas oviformis var. duplex' to 'Trachelomonas' expected", 1, edges.size());
240
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(n_trachelomonas_o_var_d,
241
                    nameDao.load(uuid_n_trachelomonas), true);
242
            Assert.assertEquals("One edge from 'Trachelomonas oviformis var. duplex' to 'Trachelomonas' expected", 1,
243
                    edges.size());
235 244
            edges = taxonGraphDao.edges(n_trachelomonas_o_var_d, nameDao.load(uuid_n_trachelomonas_o), true);
236 245
            Assert.assertEquals("One edge from 'Trachelomonas oviformis var. duplex' to 'Trachelomonas oviformis' expected", 1, edges.size());
237 246
            edges = taxonGraphDao.edges(null, nameDao.load(uuid_n_euglena), true);
......
255 264
    }
256 265

  
257 266
    @Test
258
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonGraphTest.xml")
259
    public void testChangeSpecificEpithet_of_InfraSpecific() throws TaxonGraphException{
267
    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "TaxonGraphTest.xml")
268
    public void testChangeSpecificEpithet_of_InfraSpecific() throws TaxonGraphException {
260 269

  
261 270
        try {
262 271
            setUuidPref();
......
286 295
    }
287 296

  
288 297
    @Test
289
    @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="TaxonGraphTest.xml")
290
    public void testChangeSpecificEpithet_of_Species() throws TaxonGraphException{
298
    @DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "TaxonGraphTest.xml")
299
    public void testChangeSpecificEpithet_of_Species() throws TaxonGraphException {
291 300

  
292 301
        try {
293 302
            setUuidPref();
294 303

  
295 304
            TaxonName n_trachelomonas_o = nameDao.load(uuid_n_trachelomonas_o);
296 305

  
297
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(nameDao.load(uuid_n_trachelomonas_o_var_d), n_trachelomonas_o, true);
298
            Assert.assertEquals("One edge from 'Trachelomonas oviformis var. duplex' to 'Trachelomonas oviformis' expected", 1, edges.size());
299
            edges = taxonGraphDao.edges(n_trachelomonas_o, nameDao.load(uuid_n_trachelomonas) , true);
306
            List<TaxonGraphEdgeDTO> edges = taxonGraphDao.edges(nameDao.load(uuid_n_trachelomonas_o_var_d),
307
                    n_trachelomonas_o, true);
308
            Assert.assertEquals(
309
                    "One edge from 'Trachelomonas oviformis var. duplex' to 'Trachelomonas oviformis' expected", 1,
310
                    edges.size());
311
            edges = taxonGraphDao.edges(n_trachelomonas_o, nameDao.load(uuid_n_trachelomonas), true);
300 312
            Assert.assertEquals("One edge from 'Trachelomonas oviformis' to 'Trachelomonas' expected", 1, edges.size());
301 313

  
302 314
            n_trachelomonas_o.setSpecificEpithet("robusta");
......
305 317
            n_trachelomonas_o = nameDao.load(n_trachelomonas_o.getUuid());
306 318

  
307 319
            // printDataSet(System.err,"TaxonRelationship");
308
            edges = taxonGraphDao.edges(n_trachelomonas_o, nameDao.load(uuid_n_trachelomonas) , true);
320
            edges = taxonGraphDao.edges(n_trachelomonas_o, nameDao.load(uuid_n_trachelomonas), true);
309 321
            Assert.assertEquals("The edge to Trachelomonas should still exist", 1, edges.size());
310 322
            edges = taxonGraphDao.edges(nameDao.load(uuid_n_trachelomonas_o_var_d), n_trachelomonas_o, true);
311
            Assert.assertEquals("The edge from 'Trachelomonas oviformis var. duplex' should have been deleted", 0, edges.size());
323
            Assert.assertEquals("The edge from 'Trachelomonas oviformis var. duplex' should have been deleted", 0,
324
                    edges.size());
312 325
            edges = taxonGraphDao.edges(nameDao.load(uuid_n_trachelomonas_r_s), n_trachelomonas_o, true);
313
            Assert.assertEquals("The edge to 'Trachelomonas robusta var. sparsiornata' should have been created", 1, edges.size());
326
            Assert.assertEquals("The edge to 'Trachelomonas robusta var. sparsiornata' should have been created", 1,
327
                    edges.size());
314 328

  
315 329
        } finally {
316 330
            rollback();
317 331
        }
318 332
    }
319 333

  
320

  
321 334
    /**
322 335
     * {@inheritDoc}
323 336
     */

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)