ItEr53S04ValidacionEProbasFuncionaisItEr52S04 : Adds the predefined unit type by default
This commit is contained in:
parent
3182d3cd80
commit
e41d203ade
7 changed files with 145 additions and 81 deletions
|
|
@ -57,4 +57,8 @@ public enum PredefinedUnitTypes {
|
|||
public String toString() {
|
||||
return measure;
|
||||
}
|
||||
|
||||
public static PredefinedUnitTypes defaultUnitType() {
|
||||
return UNITS;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
package org.navalplanner.business.materials.bootstrap;
|
||||
|
||||
import org.navalplanner.business.IDataBootstrap;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.materials.daos.IUnitTypeDAO;
|
||||
import org.navalplanner.business.materials.entities.UnitType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -40,17 +41,30 @@ public class UnitTypeBootstrap implements IDataBootstrap {
|
|||
@Autowired
|
||||
private IUnitTypeDAO unitTypeDAO;
|
||||
|
||||
private static UnitType defaultUnitType;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void loadRequiredData() {
|
||||
for (PredefinedUnitTypes predefinedUnitType : PredefinedUnitTypes
|
||||
.values()) {
|
||||
if (!unitTypeDAO
|
||||
.existsUnitTypeByNameInAnotherTransaction(predefinedUnitType
|
||||
.getMeasure())) {
|
||||
unitTypeDAO.save(predefinedUnitType.createUnitType());
|
||||
UnitType type = null;
|
||||
try {
|
||||
type = unitTypeDAO
|
||||
.findUniqueByNameInAnotherTransaction(predefinedUnitType
|
||||
.getMeasure());
|
||||
} catch (InstanceNotFoundException e) {
|
||||
type = predefinedUnitType.createUnitType();
|
||||
unitTypeDAO.save(type);
|
||||
}
|
||||
if (predefinedUnitType
|
||||
.equals(PredefinedUnitTypes.defaultUnitType())) {
|
||||
defaultUnitType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static UnitType getDefaultUnitType() {
|
||||
return defaultUnitType;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.hibernate.validator.NotNull;
|
||||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.materials.bootstrap.UnitTypeBootstrap;
|
||||
import org.navalplanner.business.materials.daos.IMaterialDAO;
|
||||
|
||||
/**
|
||||
* Material entity
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
|
|
@ -43,7 +43,6 @@ public class Material extends IntegrationEntity implements Comparable {
|
|||
|
||||
private Boolean disabled;
|
||||
|
||||
@NotNull
|
||||
private MaterialCategory category = null;
|
||||
|
||||
// Default constructor, needed by Hibernate
|
||||
|
|
@ -52,7 +51,9 @@ public class Material extends IntegrationEntity implements Comparable {
|
|||
}
|
||||
|
||||
public static Material create(String code) {
|
||||
return (Material) create(new Material(), code);
|
||||
Material material = (Material) create(new Material(), code);
|
||||
material.unitType = UnitTypeBootstrap.getDefaultUnitType();
|
||||
return material;
|
||||
}
|
||||
|
||||
public static Material createUnvalidated(String code, String description,
|
||||
|
|
@ -86,6 +87,7 @@ public class Material extends IntegrationEntity implements Comparable {
|
|||
this.setCode(code);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MaterialCategory getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
|
@ -118,6 +120,7 @@ public class Material extends IntegrationEntity implements Comparable {
|
|||
this.defaultUnitPrice = defaultUnitPrice;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public UnitType getUnitType() {
|
||||
return unitType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,14 @@ import static org.navalplanner.business.BusinessGlobalNames.BUSINESS_SPRING_CONF
|
|||
import static org.navalplanner.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.navalplanner.business.IDataBootstrap;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.materials.daos.IMaterialCategoryDAO;
|
||||
import org.navalplanner.business.materials.daos.IMaterialDAO;
|
||||
|
|
@ -69,6 +71,18 @@ public class MaterialDAOTest {
|
|||
assertNotNull(materialDAO);
|
||||
}
|
||||
|
||||
@Resource
|
||||
private IDataBootstrap materialCategoryBootstrap;
|
||||
|
||||
@Resource
|
||||
private IDataBootstrap unitTypeBootstrap;
|
||||
|
||||
@Before
|
||||
public void loadRequiredaData() {
|
||||
materialCategoryBootstrap.loadRequiredData();
|
||||
unitTypeBootstrap.loadRequiredData();
|
||||
}
|
||||
|
||||
private MaterialCategory createValidMaterialCategory() {
|
||||
MaterialCategory materialCategory = MaterialCategory.create(UUID.randomUUID().toString());
|
||||
return materialCategory;
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ public final class MaterialConverter {
|
|||
materialDTO.unitType);
|
||||
material.setUnitType(unitType);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
material.setUnitType(null);
|
||||
throw new ValidationException(_("unit type code not found"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.navalplanner.business.IDataBootstrap;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.materials.bootstrap.UnitTypeBootstrap;
|
||||
import org.navalplanner.business.materials.daos.IMaterialCategoryDAO;
|
||||
import org.navalplanner.business.materials.daos.IMaterialDAO;
|
||||
import org.navalplanner.business.materials.daos.IUnitTypeDAO;
|
||||
|
|
@ -52,10 +53,10 @@ import org.navalplanner.ws.materials.api.MaterialCategoryDTO;
|
|||
import org.navalplanner.ws.materials.api.MaterialCategoryListDTO;
|
||||
import org.navalplanner.ws.materials.api.MaterialDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Tests for <code>IMaterialService</code>.
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
|
|
@ -89,7 +90,21 @@ public class MaterialServiceTest {
|
|||
@Resource
|
||||
private IDataBootstrap unitTypeBootstrap;
|
||||
|
||||
private String unitTypeCodeA = "unitTypeA";
|
||||
private String unitTypeCodeA = "unitTypeCodeA";
|
||||
|
||||
private String unitTypeCodeB = "unitTypeCodeB";
|
||||
|
||||
@Test
|
||||
@Rollback(false)
|
||||
public void CreateUnitType() {
|
||||
UnitType entityA = UnitType.create(unitTypeCodeA, getUniqueName());
|
||||
UnitType entityB = UnitType.create(unitTypeCodeB, getUniqueName());
|
||||
unitTypeDAO.save(entityA);
|
||||
unitTypeDAO.save(entityB);
|
||||
unitTypeDAO.flush();
|
||||
sessionFactory.getCurrentSession().evict(entityA);
|
||||
sessionFactory.getCurrentSession().evict(entityB);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void loadRequiredaData() {
|
||||
|
|
@ -128,7 +143,7 @@ public class MaterialServiceTest {
|
|||
.addMaterials(materialCategoryListDTO).instanceConstraintViolationsList;
|
||||
|
||||
assertTrue(instanceConstraintViolationsList.toString(),
|
||||
instanceConstraintViolationsList.size() == 0);
|
||||
instanceConstraintViolationsList.size() == 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -256,7 +271,8 @@ public class MaterialServiceTest {
|
|||
|
||||
/* Build material (0 constraint violations). */
|
||||
MaterialDTO m1 = new MaterialDTO("M-1", "tornillos",
|
||||
new BigDecimal(13), unitTypeCodeA, true);
|
||||
new BigDecimal(13), UnitTypeBootstrap.getDefaultUnitType()
|
||||
.getCode(), true);
|
||||
|
||||
List<MaterialDTO> materialDTOs1 = new ArrayList<MaterialDTO>();
|
||||
materialDTOs1.add(m1);
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import javax.annotation.Resource;
|
|||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.navalplanner.business.IDataBootstrap;
|
||||
|
|
@ -124,6 +125,10 @@ public class OrderElementServiceTest {
|
|||
configurationBootstrap.loadRequiredData();
|
||||
materialCategoryBootstrap.loadRequiredData();
|
||||
criterionsBootstrap.loadRequiredData();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void loadRequiredUnitTypeData() {
|
||||
unitTypeBootstrap.loadRequiredData();
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +152,8 @@ public class OrderElementServiceTest {
|
|||
@Test
|
||||
@Rollback(false)
|
||||
public void givenLabelStored() {
|
||||
Label label = Label.create(labelCode, "labelName");
|
||||
Label label = Label.create(labelCode, "labelName "
|
||||
+ UUID.randomUUID().toString());
|
||||
|
||||
LabelType labelType = LabelType.create("label-type-"
|
||||
+ UUID.randomUUID());
|
||||
|
|
@ -191,7 +197,7 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
|
||||
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
|
||||
List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
|
||||
|
|
@ -214,7 +220,7 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
|
||||
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
|
||||
List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
|
||||
|
|
@ -256,10 +262,10 @@ public class OrderElementServiceTest {
|
|||
|
||||
@Test
|
||||
public void validOrder() {
|
||||
String code = "order-code";
|
||||
String code = "order-code " + UUID.randomUUID().toString();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -277,8 +283,8 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
OrderLineDTO orderLineDTO = new OrderLineDTO();
|
||||
|
|
@ -303,13 +309,13 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
OrderLineDTO orderLineDTO = new OrderLineDTO();
|
||||
orderLineDTO.name = "Order line";
|
||||
orderLineDTO.code = "order-line-code";
|
||||
orderLineDTO.name = "Order line " + UUID.randomUUID().toString();
|
||||
orderLineDTO.code = "order-line-code " + UUID.randomUUID().toString();
|
||||
HoursGroupDTO hoursGroupDTO = new HoursGroupDTO();
|
||||
hoursGroupDTO.resourceType = ResourceEnumDTO.WORKER;
|
||||
orderLineDTO.hoursGroups.add(hoursGroupDTO);
|
||||
|
|
@ -334,16 +340,16 @@ public class OrderElementServiceTest {
|
|||
|
||||
@Test
|
||||
public void validOrderWithOrderLine() {
|
||||
String code = "order-code";
|
||||
String code = "order-code " + UUID.randomUUID().toString();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
OrderLineDTO orderLineDTO = new OrderLineDTO();
|
||||
orderLineDTO.name = "Order line";
|
||||
orderLineDTO.code = "order-line-code";
|
||||
orderLineDTO.name = "Order line " + UUID.randomUUID().toString();
|
||||
orderLineDTO.code = "order-line-code " + UUID.randomUUID().toString();
|
||||
HoursGroupDTO hoursGroupDTO = new HoursGroupDTO("hours-group",
|
||||
ResourceEnumDTO.WORKER, 1000,
|
||||
new HashSet<CriterionRequirementDTO>());
|
||||
|
|
@ -368,8 +374,8 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
OrderLineGroupDTO orderLineGroupDTO = new OrderLineGroupDTO();
|
||||
|
|
@ -395,13 +401,15 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
OrderLineGroupDTO orderLineGroupDTO = new OrderLineGroupDTO();
|
||||
orderLineGroupDTO.name = "Order line group";
|
||||
orderLineGroupDTO.code = "order-line-group-code";
|
||||
orderLineGroupDTO.name = "Order line group "
|
||||
+ UUID.randomUUID().toString();
|
||||
orderLineGroupDTO.code = "order-line-group-code "
|
||||
+ UUID.randomUUID().toString();
|
||||
orderDTO.children.add(orderLineGroupDTO);
|
||||
|
||||
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
|
||||
|
|
@ -423,20 +431,21 @@ public class OrderElementServiceTest {
|
|||
String code = UUID.randomUUID().toString();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name A";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
OrderLineGroupDTO orderLineGroupDTO = new OrderLineGroupDTO();
|
||||
orderLineGroupDTO.name = "Order line group A";
|
||||
orderLineGroupDTO.code = "order-line-group-code-A";
|
||||
orderLineGroupDTO.name = "Order line group "
|
||||
+ UUID.randomUUID().toString();
|
||||
orderLineGroupDTO.code = "order-line-group-code "
|
||||
+ UUID.randomUUID().toString();
|
||||
|
||||
OrderLineDTO orderLineDTO = new OrderLineDTO();
|
||||
orderLineDTO.name = "Order line A";
|
||||
orderLineDTO.code = "order-line-code-A";
|
||||
orderLineDTO.name = "Order line " + UUID.randomUUID().toString();
|
||||
orderLineDTO.code = "order-line-code " + UUID.randomUUID().toString();
|
||||
HoursGroupDTO hoursGroupDTO = new HoursGroupDTO("hours-group-"
|
||||
+ UUID.randomUUID().toString(),
|
||||
ResourceEnumDTO.WORKER, 1000,
|
||||
+ UUID.randomUUID().toString(), ResourceEnumDTO.WORKER, 1000,
|
||||
new HashSet<CriterionRequirementDTO>());
|
||||
orderLineDTO.hoursGroups.add(hoursGroupDTO);
|
||||
orderLineGroupDTO.children.add(orderLineDTO);
|
||||
|
|
@ -462,8 +471,8 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
MaterialAssignmentDTO materialAssignmentDTO = new MaterialAssignmentDTO();
|
||||
|
|
@ -488,12 +497,13 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
MaterialAssignmentDTO materialAssignmentDTO = new MaterialAssignmentDTO();
|
||||
materialAssignmentDTO.materialCode = "material-code";
|
||||
materialAssignmentDTO.materialCode = "material-code "
|
||||
+ UUID.randomUUID().toString();
|
||||
orderDTO.materialAssignments.add(materialAssignmentDTO);
|
||||
|
||||
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
|
||||
|
|
@ -515,15 +525,16 @@ public class OrderElementServiceTest {
|
|||
|
||||
@Test
|
||||
public void validOrderWithMaterialAssignment() {
|
||||
String code = "order-code";
|
||||
String code = "order-code " + UUID.randomUUID().toString();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
MaterialAssignmentDTO materialAssignmentDTO = new MaterialAssignmentDTO();
|
||||
materialAssignmentDTO.materialCode = "material-code";
|
||||
materialAssignmentDTO.materialCode = "material-code "
|
||||
+ UUID.randomUUID().toString();
|
||||
materialAssignmentDTO.unitPrice = BigDecimal.TEN;
|
||||
materialAssignmentDTO.units = 100.0;
|
||||
orderDTO.materialAssignments.add(materialAssignmentDTO);
|
||||
|
|
@ -531,7 +542,8 @@ public class OrderElementServiceTest {
|
|||
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
|
||||
List<InstanceConstraintViolationsDTO> instanceConstraintViolationsList = orderElementService
|
||||
.addOrders(orderListDTO).instanceConstraintViolationsList;
|
||||
assertThat(instanceConstraintViolationsList.size(), equalTo(0));
|
||||
assertTrue(instanceConstraintViolationsList.toString(),
|
||||
instanceConstraintViolationsList.size() == 0);
|
||||
|
||||
try {
|
||||
orderElementDAO.findByCode(code);
|
||||
|
|
@ -546,8 +558,8 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
LabelReferenceDTO labelReferenceDTO = new LabelReferenceDTO();
|
||||
|
|
@ -567,10 +579,10 @@ public class OrderElementServiceTest {
|
|||
|
||||
@Test
|
||||
public void validOrderWithLabel() {
|
||||
String code = "order-code";
|
||||
String code = "order-code " + UUID.randomUUID().toString();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -596,8 +608,8 @@ public class OrderElementServiceTest {
|
|||
int previous = orderDAO.getOrders().size();
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.code = "order-code";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = "order-code " + UUID.randomUUID().toString();
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
LabelReferenceDTO labelReferenceDTO = new LabelReferenceDTO();
|
||||
|
|
@ -635,12 +647,11 @@ public class OrderElementServiceTest {
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
LabelReferenceDTO labelReferenceDTO = new LabelReferenceDTO(
|
||||
labelCode);
|
||||
LabelReferenceDTO labelReferenceDTO = new LabelReferenceDTO(labelCode);
|
||||
orderDTO.labels.add(labelReferenceDTO);
|
||||
|
||||
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
|
||||
|
|
@ -655,8 +666,7 @@ labelCode);
|
|||
orderElementDAO.flush();
|
||||
sessionFactory.getCurrentSession().evict(orderElement);
|
||||
|
||||
LabelReferenceDTO labelReferenceDTO2 = new LabelReferenceDTO(
|
||||
labelCode);
|
||||
LabelReferenceDTO labelReferenceDTO2 = new LabelReferenceDTO(labelCode);
|
||||
orderDTO.labels.add(labelReferenceDTO2);
|
||||
|
||||
orderListDTO = createOrderListDTO(orderDTO);
|
||||
|
|
@ -674,6 +684,11 @@ labelCode);
|
|||
public void updateMaterialAssignment() throws InstanceNotFoundException,
|
||||
IncompatibleTypeException {
|
||||
String code = "order-code" + UUID.randomUUID().toString();
|
||||
String materialcode1 = "material-code-1-"
|
||||
+ UUID.randomUUID().toString();
|
||||
String materialcode2 = "material-code-2-"
|
||||
+ UUID.randomUUID().toString();
|
||||
|
||||
try {
|
||||
orderElementDAO.findUniqueByCode(code);
|
||||
fail("Order with code " + code + " already exists");
|
||||
|
|
@ -682,12 +697,12 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
MaterialAssignmentDTO materialAssignmentDTO = new MaterialAssignmentDTO(
|
||||
"material-code", 100.0, BigDecimal.TEN, null);
|
||||
materialcode1, 100.0, BigDecimal.TEN, null);
|
||||
orderDTO.materialAssignments.add(materialAssignmentDTO);
|
||||
|
||||
OrderListDTO orderListDTO = createOrderListDTO(orderDTO);
|
||||
|
|
@ -705,7 +720,7 @@ labelCode);
|
|||
orderDTO.materialAssignments.iterator().next().units = 150.0;
|
||||
|
||||
MaterialAssignmentDTO materialAssignmentDTO2 = new MaterialAssignmentDTO(
|
||||
"material-code2", 200.0, BigDecimal.ONE, null);
|
||||
materialcode2, 200.0, BigDecimal.ONE, null);
|
||||
orderDTO.materialAssignments.add(materialAssignmentDTO);
|
||||
orderDTO.materialAssignments.add(materialAssignmentDTO2);
|
||||
|
||||
|
|
@ -720,12 +735,11 @@ labelCode);
|
|||
for (MaterialAssignment materialAssignment : orderElement
|
||||
.getMaterialAssignments()) {
|
||||
assertThat(materialAssignment.getMaterial().getCode(), anyOf(
|
||||
equalTo("material-code"), equalTo("material-code2")));
|
||||
equalTo(materialcode1), equalTo(materialcode2)));
|
||||
assertThat(materialAssignment.getUnits(), anyOf(equalTo(150.0),
|
||||
equalTo(200.0)));
|
||||
assertThat(materialAssignment.getUnitPrice(), anyOf(
|
||||
equalTo(BigDecimal.TEN.setScale(2)),
|
||||
equalTo(BigDecimal.ONE
|
||||
equalTo(BigDecimal.TEN.setScale(2)), equalTo(BigDecimal.ONE
|
||||
.setScale(2))));
|
||||
}
|
||||
}
|
||||
|
|
@ -742,12 +756,12 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
OrderLineDTO orderLineDTO = new OrderLineDTO();
|
||||
orderLineDTO.name = "Order line";
|
||||
orderLineDTO.name = "Order line " + UUID.randomUUID().toString();
|
||||
orderLineDTO.code = "order-line-code" + UUID.randomUUID().toString();
|
||||
HoursGroupDTO hoursGroupDTO = new HoursGroupDTO("hours-groupYY",
|
||||
ResourceEnumDTO.WORKER, 1000,
|
||||
|
|
@ -815,7 +829,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -857,7 +871,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -892,7 +906,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -957,7 +971,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -987,7 +1001,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -1021,7 +1035,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -1033,11 +1047,10 @@ labelCode);
|
|||
orderDTO.criterionRequirements.add(criterionRequirementDTO);
|
||||
|
||||
OrderLineDTO orderLineDTO = new OrderLineDTO();
|
||||
orderLineDTO.name = "Order line";
|
||||
orderLineDTO.name = "Order line " + UUID.randomUUID().toString();
|
||||
orderLineDTO.code = "order-line-code-AX";
|
||||
HoursGroupDTO hoursGroupDTO = new HoursGroupDTO("hours-group"
|
||||
+ UUID.randomUUID().toString(),
|
||||
ResourceEnumDTO.WORKER, 1000,
|
||||
+ UUID.randomUUID().toString(), ResourceEnumDTO.WORKER, 1000,
|
||||
new HashSet<CriterionRequirementDTO>());
|
||||
orderLineDTO.hoursGroups.add(hoursGroupDTO);
|
||||
IndirectCriterionRequirementDTO indirectCriterionRequirementDTO = new IndirectCriterionRequirementDTO(
|
||||
|
|
@ -1073,7 +1086,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
@ -1134,7 +1147,7 @@ labelCode);
|
|||
}
|
||||
|
||||
OrderDTO orderDTO = new OrderDTO();
|
||||
orderDTO.name = "Order name";
|
||||
orderDTO.name = "Order name " + UUID.randomUUID().toString();
|
||||
orderDTO.code = code;
|
||||
orderDTO.initDate = new Date();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue