Project

General

Profile

Revision f6299e47

IDf6299e47026d65cf7b44ae3aefccc6b0c84934b5
Parent 1b70bad3
Child 92a6aa38

Added by Andreas Kohlbecker over 4 years ago

#4366 test for aggregation of distribution sources (byArea)

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/TransmissionEngineDistribution.java
452 452
                TaxonDescription description = findComputedDescription(taxon, doClearDescriptions);
453 453
                List<Distribution> distributions = distributionsFor(taxon);
454 454

  
455

  
456 455
                // Step through superAreas for accumulation of subAreas
457 456
                for (NamedArea superArea : superAreaList){
458 457

  
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TransmissionEngineDistributionTest.java
10 10
package eu.etaxonomy.cdm.api.service;
11 11

  
12 12
import static org.junit.Assert.assertEquals;
13
import static org.junit.Assert.assertTrue;
13
import static org.junit.Assert.assertNotNull;
14
import static org.junit.Assert.assertNull;
14 15

  
15 16
import java.io.FileNotFoundException;
16 17
import java.util.Arrays;
......
28 29
import eu.etaxonomy.cdm.api.service.description.TransmissionEngineDistribution;
29 30
import eu.etaxonomy.cdm.api.service.description.TransmissionEngineDistribution.AggregationMode;
30 31
import eu.etaxonomy.cdm.model.common.Extension;
32
import eu.etaxonomy.cdm.model.common.MarkerType;
31 33
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
34
import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
32 35
import eu.etaxonomy.cdm.model.description.Distribution;
33 36
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
34 37
import eu.etaxonomy.cdm.model.description.TaxonDescription;
......
183 186
    })
184 187
    public void testArea_area() {
185 188

  
189
        Distribution[] distributions = new Distribution[4];
190

  
191
        Reference book_LCA_yug_mn = ReferenceFactory.newBook();
192
        book_LCA_yug_mn.setTitle("LCA_yug_mn");
193
        DescriptionElementSource.NewPrimarySourceInstance(book_LCA_yug_mn, "1");
194
        distributions[0] = Distribution.NewInstance(yug_mn, PresenceAbsenceTerm.CULTIVATED());
195

  
196
        Reference book_LCA_yug_ko = ReferenceFactory.newBook();
197
        book_LCA_yug_mn.setTitle("LCA_yug_ko");
198
        DescriptionElementSource.NewPrimarySourceInstance(book_LCA_yug_ko, "2");
199
        distributions[1] = Distribution.NewInstance(yug_ko, PresenceAbsenceTerm.NATIVE()); // NATIVE should succeed
200

  
201
        Reference book_LCA_yug_bh = ReferenceFactory.newBook();
202
        book_LCA_yug_mn.setTitle("LCA_yug_bh");
203
        DescriptionElementSource.NewPrimarySourceInstance(book_LCA_yug_bh, "3");
204
        distributions[2] = Distribution.NewInstance(yug_bh, PresenceAbsenceTerm.INTRODUCED());
205

  
206
        Reference book_LCA_yug_ma = ReferenceFactory.newBook();
207
        book_LCA_yug_mn.setTitle("LCA_yug_ma");
208
        DescriptionElementSource.NewPrimarySourceInstance(book_LCA_yug_ma, "4");
209
        distributions[3] = Distribution.NewInstance(yug_ma, PresenceAbsenceTerm.NATIVE()); // NATIVE should succeed
210

  
186 211
        addDistributions(
187 212
                T_LAPSANA_COMMUNIS_ALPINA_UUID,
188
                new Distribution[] {
189
                        Distribution.NewInstance(yug_mn, PresenceAbsenceTerm.CULTIVATED()),
190
                        Distribution.NewInstance(yug_ko, PresenceAbsenceTerm.NATIVE()), // should succeed
191
                        Distribution.NewInstance(yug_bh, PresenceAbsenceTerm.INTRODUCED())
192
               }
213
                distributions
193 214
            );
194 215

  
195 216
        Taxon lapsana_communis_alpina  = (Taxon) taxonService.load(T_LAPSANA_COMMUNIS_ALPINA_UUID);
......
200 221
        lapsana_communis_alpina  = (Taxon) taxonService.load(T_LAPSANA_COMMUNIS_ALPINA_UUID);
201 222
        assertEquals(2, lapsana_communis_alpina.getDescriptions().size());
202 223

  
203
        boolean expectedAreaFound = false;
224
        Distribution accumulatedDistribution = null;
204 225
        for (TaxonDescription description : lapsana_communis_alpina.getDescriptions()) {
205
            Distribution distribution = (Distribution) description.getElements().iterator().next(); // only one aggregated area expected
206
            if(distribution.getArea().equals(yug)) {
207
                expectedAreaFound = true;
208
                assertEquals("aggregated status of area YUG is wrong", PresenceAbsenceTerm.NATIVE().getLabel(), distribution.getStatus().getLabel());
226
            if(description.hasMarker(MarkerType.COMPUTED(), true)) {
227
                assertNull("only one computed Distribution should exists", accumulatedDistribution);
228
                assertEquals("the computed Decription should have only one element", 1, description.getElements().size());
229
                accumulatedDistribution = (Distribution) description.getElements().iterator().next();
230
                assertEquals("Expecting area to be YUG", yug, accumulatedDistribution.getArea());
231
                assertEquals("Expecting status to be NATIVE", PresenceAbsenceTerm.NATIVE().getLabel(), accumulatedDistribution.getStatus().getLabel());
209 232
            }
210 233
        }
211
        assertTrue("The areae YUG should have been found", expectedAreaFound);
234
        assertNotNull("The area YUG should have been found", accumulatedDistribution);
235
//        assertEquals("Expecting two source references", accumulatedDistribution.getSources().size());
236
//        assertTrue(accumulatedDistribution.getSources().contains(book_LCA_yug_ko));
237
//        assertTrue(accumulatedDistribution.getSources().contains(book_LCA_yug_ma));
212 238
    }
213 239

  
214 240
    @Test

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)