Project

General

Profile

« Previous | Next » 

Revision 7e898982

Added by Andreas Kohlbecker over 6 years ago

ref #7114 fixing bug in DerivedUnitConverterIntegrationTest and NPE in DerivedUnitConverter

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/utility/DerivedUnitConverter.java
106 106
        n.setCatalogNumber(source.getCatalogNumber());
107 107
        n.setCollection(source.getCollection());
108 108
        DerivationEvent derivationEvent = source.getDerivedFrom();
109
        derivationEvent.getDerivatives().remove(source);
109
        if(derivationEvent != null){
110
            derivationEvent.getDerivatives().remove(source);
111
        }
110 112
        n.setDerivedFrom(source.getDerivedFrom());
111 113
        source.setDerivedFrom(null);
112 114
        n.setExsiccatum(source.getExsiccatum());
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/utility/DerivedUnitConverterIntegrationTest.java
56 56
        du.setTitleCache("test derived unit", true);
57 57
        du = (DerivedUnit) service.save(du); // intermediate save is essential for this test
58 58
        DerivedUnitConverter<MediaSpecimen> duc = DerivedUnitConverterFactory.createDerivedUnitConverter(du, MediaSpecimen.class);
59
        MediaSpecimen target = duc.convertTo(MediaSpecimen.class, SpecimenOrObservationType.StillImage);
60
        service.save(target);
59
        duc.convertTo(MediaSpecimen.class, SpecimenOrObservationType.StillImage);
61 60

  
62 61
        assertEquals(1, service.list(null, null, null, null, null).size());
63 62
        assertEquals(1, service.list(MediaSpecimen.class, null, null, null, null).size());
......
78 77
        du.setTitleCache("test media specimen", true);
79 78
        DerivedUnitConverter<DerivedUnit> duc = DerivedUnitConverterFactory.createDerivedUnitConverter(du, DerivedUnit.class);
80 79
        du = (MediaSpecimen) service.save(du); // intermediate save is essential for this test
81
        DerivedUnit target = duc.convertTo(DerivedUnit.class, SpecimenOrObservationType.PreservedSpecimen);
82
        service.save(target);
80
        duc.convertTo(DerivedUnit.class, SpecimenOrObservationType.PreservedSpecimen);
83 81

  
84 82
        assertEquals(1, service.list(null, null, null, null, null).size());
85 83
        assertEquals(1, service.list(DerivedUnit.class, null, null, null, null).size());

Also available in: Unified diff