package org.col.db.mapper;

import org.col.api.TestEntityGenerator;
import org.col.api.model.ColSource;
import org.col.api.model.EditorialDecision;
import org.col.api.model.Sector;
import org.col.api.vocab.TaxonomicStatus;
import org.junit.Before;

import static org.col.api.TestEntityGenerator.DATASET11;
import static org.col.api.TestEntityGenerator.newNameRef;

public class DecisionMapperTest extends CRUDIntMapperTest<EditorialDecision, DecisionMapper> {
  
  private ColSource source;
  private Sector sector;
  
  public DecisionMapperTest() {
    super(DecisionMapper.class);
  }
  
  @Before
  public void initSource() {
    source = ColSourceMapperTest.create(DATASET11.getKey());
    mapper(ColSourceMapper.class).create(source);
    
    sector = SectorMapperTest.create(source.getKey());
    mapper(SectorMapper.class).create(sector);
    
    commit();
  }
  
  
  @Override
  void updateTestObj(EditorialDecision ed) {
    ed.setNote("My next note");
    ed.setName(TestEntityGenerator.newName("updatedID"));
  }
  
  @Override
  EditorialDecision createTestEntity() {
    return create(sector.getKey());
  }

  public static EditorialDecision create(int sectorKey) {
    EditorialDecision d = new EditorialDecision();
    d.setSectorKey(sectorKey);
    d.setSubject(newNameRef());
    d.setMode(EditorialDecision.Mode.CREATE);
    d.setName(TestEntityGenerator.newName());
    d.setStatus(TaxonomicStatus.AMBIGUOUS_SYNONYM);
    d.setNote("I cannot remember why I did this.");
    d.setCreatedBy(TestEntityGenerator.USER_EDITOR.getKey());
    d.setModifiedBy(d.getCreatedBy());
    return d;
  }
  
  @Override
  EditorialDecision removeDbCreatedProps(EditorialDecision obj) {
    obj.setCreated(null);
    obj.setModified(null);
    return obj;
  }
  
}
@@ -145,41 +145,8 @@
 on;%0A
-import org.col.api.model.Sector;%0A
 impo
@@ -455,33 +455,8 @@
 ce;%0A
-  private Sector sector;%0A
   %0A 
@@ -685,115 +685,8 @@
    %0A
-    sector = SectorMapperTest.create(source.getKey());%0A    mapper(SectorMapper.class).create(sector);%0A    %0A
     
@@ -931,21 +931,21 @@
 create(s
-ector
+ource
 .getKey(
@@ -999,21 +999,21 @@
 te(int s
-ector
+ource
 Key) %7B%0A 
@@ -1075,24 +1075,27 @@
 .set
-SectorKey(sector
+ColSourceKey(source
 Key)

Fix decision mapper