Bugfixes nach CLI-basierten Integrationstest im TomEE2

This commit is contained in:
Michael Hoennig 2017-04-15 15:54:42 +02:00
parent 87d698f828
commit cc2a17c81a
3 changed files with 37 additions and 9 deletions

View File

@ -93,7 +93,7 @@ public class MemberShare implements Serializable {
@Override @Override
public String toString() { public String toString() {
return "MemberShare [id=" + id + ", customer=" + customer.getName() + ", date=" + date + ", action=" + action return "MemberShare [id=" + id + ", customer=" + (customer!=null ? customer.getName() : null) + ", date=" + date + ", action=" + action
+ ", quantity=" + quantity + ", comment=" + comment + "]"; + ", quantity=" + quantity + ", comment=" + comment + "]";
} }
} }

View File

@ -10,7 +10,6 @@ import de.hsadmin.module.property.ReadWritePolicy;
import de.hsadmin.module.property.Required; import de.hsadmin.module.property.Required;
import de.hsadmin.module.property.Search; import de.hsadmin.module.property.Search;
import de.hsadmin.module.property.SearchPolicy; import de.hsadmin.module.property.SearchPolicy;
import de.hsadmin.module.property.mapping.DefaultEnumParameterMapMapper;
import de.hsadmin.module.property.mapping.DefaultEnumPersistentObjectMapper; import de.hsadmin.module.property.mapping.DefaultEnumPersistentObjectMapper;
import de.hsadmin.module.property.mapping.DefaultStringParameterMapMapper; import de.hsadmin.module.property.mapping.DefaultStringParameterMapMapper;
import de.hsadmin.module.property.mapping.Mapping; import de.hsadmin.module.property.mapping.Mapping;
@ -27,7 +26,7 @@ public class MemberShareVO extends AbstractVO implements ValueObject {
private String customer; private String customer;
@Mapping(boMapping=DefaultEnumPersistentObjectMapper.class, @Mapping(boMapping=DefaultEnumPersistentObjectMapper.class,
rpcMapping=DefaultEnumParameterMapMapper.class, rpcMapping=DefaultStringParameterMapMapper.class,
boMappingPath="customer.name") boMappingPath="customer.name")
@ReadWrite(ReadWritePolicy.WRITEONCE) @ReadWrite(ReadWritePolicy.WRITEONCE)
@Required(true) @Required(true)

View File

@ -1,21 +1,20 @@
package de.hsadmin.service.customer; package de.hsadmin.service.customer;
import static junitparams.JUnitParamsRunner.$;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import org.h2.command.ddl.CreateAggregate;
import static junitparams.JUnitParamsRunner.$;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import de.hsadmin.bo.customer.MemberShare;
import de.hsadmin.bo.customer.MemberShareTest;
import de.hsadmin.common.error.TechnicalException; import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.common.error.UserException; import de.hsadmin.common.error.UserException;
import de.hsadmin.dao.customer.CustomerDaoTest;
import de.hsadmin.module.impl.ValidationDelegate; import de.hsadmin.module.impl.ValidationDelegate;
import de.hsadmin.module.property.Property; import de.hsadmin.module.property.Property;
import junitparams.JUnitParamsRunner; import junitparams.JUnitParamsRunner;
@ -34,6 +33,8 @@ public class MemberShareVOTest {
private static final int INITIAL_QUANTITY = 4; private static final int INITIAL_QUANTITY = 4;
private static final String INITIALIZED_MEMBER_SHARE_VO_AS_STRING = "MemberShareVO [customer=initCust, action=SUBSCRIPTION, date=Thu Dec 26 00:00:00 CET 1996, quantity=4, comment=initial comment]";
private final ValidationDelegate<MemberShareVO> validator = new ValidationDelegate<MemberShareVO>(); private final ValidationDelegate<MemberShareVO> validator = new ValidationDelegate<MemberShareVO>();
@Rule @Rule
@ -51,7 +52,35 @@ public class MemberShareVOTest {
// koennten auch andere Tests fehlschlagen. // koennten auch andere Tests fehlschlagen.
// Wenn Felder aus dem toString() herausgenommen werden, // Wenn Felder aus dem toString() herausgenommen werden,
// koennten sogar andere Tests stillschweigend wirkungslos werden! // koennten sogar andere Tests stillschweigend wirkungslos werden!
assertEquals("MemberShareVO [customer=initCust, action=SUBSCRIPTION, date=Thu Dec 26 00:00:00 CET 1996, quantity=4, comment=initial comment]", vo.toString()); assertEquals(INITIALIZED_MEMBER_SHARE_VO_AS_STRING, vo.toString());
}
@Test
public void copyPropertiesFromPersistentObject() throws TechnicalException, UserException {
// given
MemberShare bo = MemberShareTest.createNewMemberShare(CustomerDaoTest.createNewCustomer(10001, "testCust"));
// when
MemberShareVO vo = new MemberShareVO();
vo.copyPropertiesFromPersistentObject(bo);
// then
assertEquals("MemberShareVO [customer=testCust, action=SUBSCRIPTION, date=Thu Apr 13 00:00:00 CEST 2017, quantity=5, comment=test comment]",
vo.toString());
}
@Test
public void copyPropertiesToPersistentObject() throws TechnicalException, UserException {
// given
MemberShareVO vo = givenInitializedMemberShareVOForCustomer(INITIAL_CUSTOMER);
// when
MemberShare bo = new MemberShare();
vo.copyPropertiesToPersistentObject(bo);
// then (Achtung: customer muss vom Service umkopiert werden)
assertEquals("MemberShare [id=0, customer=null, date=Thu Dec 26 00:00:00 CET 1996, action=SUBSCRIPTION, quantity=4, comment=initial comment]",
bo.toString());
} }
// --- generic tests --- // --- generic tests ---