From d9d482bdeb3890e485b142ca43e7d66ed1e361ca Mon Sep 17 00:00:00 2001 From: Susana Montes Pedreira Date: Tue, 15 Nov 2011 09:50:17 +0100 Subject: [PATCH] Create the entity SubcontractorComunication, the dao SubcontractorComunicationDAO, the test SubcontractorComunicationDAOTest and add the changes of the database in a new file db.changelog-1.2.xml FEA: ItEr75S30SubcontractorIncommingCommunicationsLists --- .../daos/ISubcontractorComunicationDAO.java | 34 +++ .../daos/SubcontractorComunicationDAO.java | 55 ++++ .../entities/SubcontractorComunication.java | 127 +++++++++ .../SubcontractorComunicationValue.java | 111 ++++++++ .../src/main/resources/db.changelog-1.2.xml | 27 ++ .../libreplan-business-spring-config.xml | 3 + .../SubcontractorComunication.hbm.xml | 34 +++ .../SubcontractorComunicationDAOTest.java | 254 ++++++++++++++++++ .../libreplan-business-spring-config-test.xml | 3 + .../libreplan-webapp-spring-config-test.xml | 3 + 10 files changed, 651 insertions(+) create mode 100644 libreplan-business/src/main/java/org/libreplan/business/planner/daos/ISubcontractorComunicationDAO.java create mode 100644 libreplan-business/src/main/java/org/libreplan/business/planner/daos/SubcontractorComunicationDAO.java create mode 100644 libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunication.java create mode 100644 libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunicationValue.java create mode 100644 libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorComunication.hbm.xml create mode 100644 libreplan-business/src/test/java/org/libreplan/business/test/planner/daos/SubcontractorComunicationDAOTest.java diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/daos/ISubcontractorComunicationDAO.java b/libreplan-business/src/main/java/org/libreplan/business/planner/daos/ISubcontractorComunicationDAO.java new file mode 100644 index 000000000..e00763f3a --- /dev/null +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/daos/ISubcontractorComunicationDAO.java @@ -0,0 +1,34 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e + * Desenvolvemento Tecnolóxico de Galicia + * Copyright (C) 2010-2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.business.planner.daos; + +import java.util.List; + +import org.libreplan.business.common.daos.IGenericDAO; +import org.libreplan.business.planner.entities.SubcontractorComunication; + +public interface ISubcontractorComunicationDAO extends IGenericDAO { + + List getAll(); + + List getAllNotReviewed(); +} diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/daos/SubcontractorComunicationDAO.java b/libreplan-business/src/main/java/org/libreplan/business/planner/daos/SubcontractorComunicationDAO.java new file mode 100644 index 000000000..929fc032c --- /dev/null +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/daos/SubcontractorComunicationDAO.java @@ -0,0 +1,55 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e + * Desenvolvemento Tecnolóxico de Galicia + * Copyright (C) 2010-2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.business.planner.daos; + +import java.util.List; + +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.libreplan.business.common.daos.GenericDAOHibernate; +import org.libreplan.business.planner.entities.SubcontractorComunication; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Repository; + +/** + * DAO for {@link SubcontractorComunication} + * @author Susana Montes Pedreira + */ + +@Repository +@Scope(BeanDefinition.SCOPE_SINGLETON) +public class SubcontractorComunicationDAO extends GenericDAOHibernate + implements ISubcontractorComunicationDAO { + + @Override + public List getAll() { + return list(SubcontractorComunication.class); + } + + @Override + public List getAllNotReviewed(){ + Criteria c = getSession().createCriteria(SubcontractorComunication.class); + c.add(Restrictions.eq("reviewed", false)); + return c.list(); + } +} diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunication.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunication.java new file mode 100644 index 000000000..495b28228 --- /dev/null +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunication.java @@ -0,0 +1,127 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e + * Desenvolvemento Tecnolóxico de Galicia + * Copyright (C) 2010-2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.business.planner.entities; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.hibernate.validator.NotNull; +import org.libreplan.business.common.BaseEntity; +import org.libreplan.business.externalcompanies.entities.ComunicationType; +import org.libreplan.business.qualityforms.entities.QualityFormItem; + +/** + * Entity {@link SubcontractorComunication}. + * + * @author Susana Montes Pedreira + */ +public class SubcontractorComunication extends BaseEntity { + + private SubcontractedTaskData subcontractedTaskData; + + private ComunicationType comunicationType; + + private Date comunicationDate; + + private Boolean reviewed = false; + + private List subcontratorComunicationValues = new ArrayList(); + + // Default constructor, needed by Hibernate + protected SubcontractorComunication() { + + } + + private SubcontractorComunication ( SubcontractedTaskData subcontractedTaskData, ComunicationType comunicationType, Date comunicationDate, Boolean reviewed){ + this.setSubcontractedTaskData(subcontractedTaskData); + this.setComunicationType(comunicationType); + this.setComunicationDate(comunicationDate); + this.setReviewed(reviewed); + } + + public static SubcontractorComunication create( + SubcontractedTaskData subcontractedTaskData, + ComunicationType comunicationType, Date comunicationDate, + Boolean reviewed) { + return new SubcontractorComunication(subcontractedTaskData, + comunicationType, comunicationDate, reviewed); + } + + public static SubcontractorComunication create() { + return new SubcontractorComunication(); + } + + public void setSubcontractedTaskData(SubcontractedTaskData subcontractedTaskData) { + this.subcontractedTaskData = subcontractedTaskData; + } + + @NotNull(message="subcontrated task data not specified") + public SubcontractedTaskData getSubcontractedTaskData() { + return subcontractedTaskData; + } + + public void setComunicationType(ComunicationType comunicationType) { + this.comunicationType = comunicationType; + } + + public ComunicationType getComunicationType() { + return comunicationType; + } + + public void setComunicationDate(Date comunicationDate) { + this.comunicationDate = comunicationDate; + } + + public Date getComunicationDate() { + return comunicationDate; + } + + public void setReviewed(Boolean reviewed) { + this.reviewed = reviewed; + } + + public Boolean getReviewed() { + return reviewed; + } + + public void setSubcontratorComunicationValues( + List subcontratorComunicationValues) { + this.subcontratorComunicationValues = subcontratorComunicationValues; + } + + public List getSubcontratorComunicationValues() { + return subcontratorComunicationValues; + } + + public SubcontractorComunicationValue getLastSubcontratorComunicationValues(){ + if (subcontratorComunicationValues.isEmpty()){ + return null; + } + return subcontratorComunicationValues.get(subcontratorComunicationValues.size()-1); + } + + public Date getLastSubcontratorComunicationValueDate(){ + SubcontractorComunicationValue value = getLastSubcontratorComunicationValues(); + return (value == null) ? null : value.getDate(); + } +} \ No newline at end of file diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunicationValue.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunicationValue.java new file mode 100644 index 000000000..6b5f88b80 --- /dev/null +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/SubcontractorComunicationValue.java @@ -0,0 +1,111 @@ +/* + * This file is part of NavalPlan + * + * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e + * Desenvolvemento Tecnolóxico de Galicia + * Copyright (C) 2010-2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.business.planner.entities; + +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.hibernate.validator.AssertTrue; +import org.libreplan.business.INewObject; + +/** + * Entity to represent each {@SubcontractorComunicationValue}. + * + * @author Susana Montes Pedreira + */ +public class SubcontractorComunicationValue implements INewObject { + + public final static String propertyDate = "date"; + + public final static String propertyProgress = "progress"; + + public static SubcontractorComunicationValue create() { + SubcontractorComunicationValue subcontractorComunicationValue = new SubcontractorComunicationValue(); + subcontractorComunicationValue.setNewObject(true); + return subcontractorComunicationValue; + } + + public static SubcontractorComunicationValue create(Date date, + BigDecimal progress) { + SubcontractorComunicationValue subcontractorComunicationValue = new SubcontractorComunicationValue( + date, progress); + subcontractorComunicationValue.setNewObject(true); + return subcontractorComunicationValue; + } + + public SubcontractorComunicationValue() { + + } + + public SubcontractorComunicationValue(Date date, BigDecimal progress) { + this.setDate(date); + this.setProgress(progress); + } + + private boolean newObject = false; + + private Date date; + + private BigDecimal progress; + + public boolean isNewObject() { + return newObject; + } + + private void setNewObject(boolean newObject) { + this.newObject = newObject; + } + + @SuppressWarnings("unused") + @AssertTrue(message = "progress should be greater than 0% and less than 100%") + public boolean checkConstraintQualityFormItemPercentage() { + if (getProgress() == null) { + return true; + } + return ((getProgress().compareTo(new BigDecimal(100).setScale(2)) <= 0) && (getProgress() + .compareTo(new BigDecimal(0).setScale(2)) > 0)); + } + + public void setDate(Date date) { + this.date = date; + } + + public Date getDate() { + return date; + } + + public void setProgress(BigDecimal progress) { + this.progress = progress; + } + + public BigDecimal getProgress() { + return progress; + } + + @Override + public String toString() { + String datetime = (date == null) ? "" : new SimpleDateFormat( + "dd/MM/yyyy HH:mm").format(date); + return progress.toString() + " - " + datetime; + } +} diff --git a/libreplan-business/src/main/resources/db.changelog-1.2.xml b/libreplan-business/src/main/resources/db.changelog-1.2.xml index ecb610e1b..99ea424a4 100644 --- a/libreplan-business/src/main/resources/db.changelog-1.2.xml +++ b/libreplan-business/src/main/resources/db.changelog-1.2.xml @@ -18,4 +18,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libreplan-business/src/main/resources/libreplan-business-spring-config.xml b/libreplan-business/src/main/resources/libreplan-business-spring-config.xml index b3f6ee43a..4fc2488df 100644 --- a/libreplan-business/src/main/resources/libreplan-business-spring-config.xml +++ b/libreplan-business/src/main/resources/libreplan-business-spring-config.xml @@ -81,6 +81,9 @@ org/libreplan/business/planner/entities/AdvanceConsolidations.hbm.xml + + org/libreplan/business/planner/entities/SubcontractorComunication.hbm.xml + org/libreplan/business/scenarios/entities/Scenarios.hbm.xml diff --git a/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorComunication.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorComunication.hbm.xml new file mode 100644 index 000000000..015eb723e --- /dev/null +++ b/libreplan-business/src/main/resources/org/libreplan/business/planner/entities/SubcontractorComunication.hbm.xml @@ -0,0 +1,34 @@ + + + + + + + + + 100 + + + + + + + org.libreplan.business.externalcompanies.entities.ComunicationType + + + + + + + + + + + + + + + + + + diff --git a/libreplan-business/src/test/java/org/libreplan/business/test/planner/daos/SubcontractorComunicationDAOTest.java b/libreplan-business/src/test/java/org/libreplan/business/test/planner/daos/SubcontractorComunicationDAOTest.java new file mode 100644 index 000000000..5f95c4372 --- /dev/null +++ b/libreplan-business/src/test/java/org/libreplan/business/test/planner/daos/SubcontractorComunicationDAOTest.java @@ -0,0 +1,254 @@ +/* + * This file is part of NavalPlan + * + * Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e + * Desenvolvemento Tecnolóxico de Galicia + * Copyright (C) 2010-2011 Igalia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.business.test.planner.daos; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; +import static org.libreplan.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE; +import static org.libreplan.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +import org.hibernate.SessionFactory; +import org.joda.time.LocalDate; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.libreplan.business.calendars.daos.IBaseCalendarDAO; +import org.libreplan.business.calendars.entities.BaseCalendar; +import org.libreplan.business.common.IAdHocTransactionService; +import org.libreplan.business.common.IOnTransaction; +import org.libreplan.business.common.daos.IConfigurationDAO; +import org.libreplan.business.common.exceptions.InstanceNotFoundException; +import org.libreplan.business.common.exceptions.ValidationException; +import org.libreplan.business.externalcompanies.daos.ICustomerComunicationDAO; +import org.libreplan.business.externalcompanies.daos.IExternalCompanyDAO; +import org.libreplan.business.externalcompanies.entities.ComunicationType; +import org.libreplan.business.externalcompanies.entities.CustomerComunication; +import org.libreplan.business.externalcompanies.entities.ExternalCompany; +import org.libreplan.business.orders.daos.IOrderDAO; +import org.libreplan.business.orders.entities.HoursGroup; +import org.libreplan.business.orders.entities.Order; +import org.libreplan.business.orders.entities.OrderLine; +import org.libreplan.business.orders.entities.SchedulingDataForVersion; +import org.libreplan.business.orders.entities.TaskSource; +import org.libreplan.business.orders.entities.TaskSource.TaskSourceSynchronization; +import org.libreplan.business.planner.daos.ISubcontractedTaskDataDAO; +import org.libreplan.business.planner.daos.ISubcontractorComunicationDAO; +import org.libreplan.business.planner.daos.ITaskElementDAO; +import org.libreplan.business.planner.daos.ITaskSourceDAO; +import org.libreplan.business.planner.entities.SubcontractedTaskData; +import org.libreplan.business.planner.entities.SubcontractorComunication; +import org.libreplan.business.planner.entities.Task; +import org.libreplan.business.scenarios.IScenarioManager; +import org.libreplan.business.scenarios.bootstrap.IScenariosBootstrap; +import org.libreplan.business.scenarios.entities.OrderVersion; +import org.libreplan.business.test.calendars.entities.BaseCalendarTest; +import org.libreplan.business.test.externalcompanies.daos.ExternalCompanyDAOTest; +import org.libreplan.business.workreports.entities.WorkReportLine; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.transaction.annotation.Transactional; +import static org.junit.Assert.assertTrue; + +/** + * Tests for {@link SubcontractorComunication} + * + * @author Susana Montes Pedreira + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { BUSINESS_SPRING_CONFIG_FILE, + BUSINESS_SPRING_CONFIG_TEST_FILE }) +@Transactional +public class SubcontractorComunicationDAOTest { + + @Autowired + ISubcontractorComunicationDAO subcontractorComunicationDAO; + + @Autowired + ISubcontractedTaskDataDAO subcontractedTaskDataDAO; + + @Autowired + IExternalCompanyDAO externalCompanyDAO; + + @Autowired + private ITaskElementDAO taskElementDAO; + + @Autowired + private IOrderDAO orderDAO; + + @Autowired + private ITaskSourceDAO taskSourceDAO; + + @Autowired + private SessionFactory sessionFactory; + + @Autowired + private IConfigurationDAO configurationDAO; + + @Autowired + private IScenarioManager scenarioManager; + + @Autowired + private IBaseCalendarDAO calendarDAO; + + @Autowired + private IScenariosBootstrap scenariosBootstrap; + + @Before + public void loadRequiredData() { + scenariosBootstrap.loadRequiredData(); + } + + private HoursGroup associatedHoursGroup; + + private ExternalCompany getSubcontractorExternalCompanySaved() { + ExternalCompany externalCompany = ExternalCompanyDAOTest + .createValidExternalCompany(); + externalCompany.setSubcontractor(true); + + externalCompanyDAO.save(externalCompany); + externalCompanyDAO.flush(); + sessionFactory.getCurrentSession().evict(externalCompany); + + externalCompany.dontPoseAsTransientObjectAnymore(); + + return externalCompany; + } + + private OrderLine createOrderLine() { + OrderLine orderLine = OrderLine.create(); + orderLine.setName("bla"); + orderLine.setCode("code-" + UUID.randomUUID()); + HoursGroup hoursGroup = new HoursGroup(); + hoursGroup.setCode("hours-group-code-" + UUID.randomUUID()); + orderLine.addHoursGroup(hoursGroup); + Order order = Order.create(); + OrderVersion orderVersion = ResourceAllocationDAOTest + .setupVersionUsing(scenarioManager, order); + order.setName("bla-" + UUID.randomUUID()); + order.setInitDate(new Date()); + order.setCode("code-" + UUID.randomUUID()); + order.useSchedulingDataFor(orderVersion); + order.add(orderLine); + + //add a basic calendar + BaseCalendar basicCalendar = BaseCalendarTest.createBasicCalendar(); + calendarDAO.save(basicCalendar); + order.setCalendar(basicCalendar); + + try { + orderDAO.save(order); + sessionFactory.getCurrentSession().flush(); + } catch (ValidationException e) { + throw new RuntimeException(e); + } + return orderLine; + } + + private Task createValidTask() { + associatedHoursGroup = new HoursGroup(); + associatedHoursGroup.setCode("hours-group-code-" + UUID.randomUUID()); + OrderLine orderLine = createOrderLine(); + orderLine.addHoursGroup(associatedHoursGroup); + OrderVersion orderVersion = ResourceAllocationDAOTest + .setupVersionUsing(scenarioManager, + orderLine.getOrder()); + orderLine.useSchedulingDataFor(orderVersion); + SchedulingDataForVersion schedulingDataForVersion = orderLine + .getCurrentSchedulingDataForVersion(); + TaskSource taskSource = TaskSource.create(schedulingDataForVersion, + Arrays.asList(associatedHoursGroup)); + TaskSourceSynchronization mustAdd = TaskSource.mustAdd(taskSource); + mustAdd.apply(TaskSource.persistTaskSources(taskSourceDAO)); + Task task = (Task) taskSource.getTask(); + return task; + } + + public SubcontractedTaskData createValidSubcontractedTaskData(String name) { + Task task = createValidTask(); + SubcontractedTaskData subcontractedTaskData = SubcontractedTaskData + .create(task); + subcontractedTaskData.setExternalCompany(getSubcontractorExternalCompanySaved()); + + task.setSubcontractedTaskData(subcontractedTaskData); + taskElementDAO.save(task); + taskElementDAO.flush(); + sessionFactory.getCurrentSession().evict(task); + sessionFactory.getCurrentSession().evict(subcontractedTaskData); + + subcontractedTaskDataDAO.save(subcontractedTaskData); + return subcontractedTaskData; + } + + public SubcontractorComunication createValidSubcontractorComunication(){ + SubcontractedTaskData subcontractedTaskData = createValidSubcontractedTaskData("Task A"); + Date comunicationDate = new Date(); + SubcontractorComunication subcontractorComunication = SubcontractorComunication + .create(subcontractedTaskData, ComunicationType.NEW_PROJECT, + comunicationDate, false); + return subcontractorComunication; + } + + @Test + public void testSubcontractorComunicationDAOInSpringContainer() { + assertNotNull(subcontractorComunicationDAO); + } + + @Test + public void testSaveCustomerComunication() { + SubcontractorComunication subcontractorComunication = createValidSubcontractorComunication(); + subcontractorComunicationDAO.save(subcontractorComunication); + assertTrue(subcontractorComunication.getId() != null); + } + + @Test + public void testRemoveCustomerComunication() + throws InstanceNotFoundException { + SubcontractorComunication customerComunication = createValidSubcontractorComunication(); + subcontractorComunicationDAO.save(customerComunication); + assertTrue(customerComunication.getId() != null); + subcontractorComunicationDAO.remove(customerComunication.getId()); + assertFalse(subcontractorComunicationDAO + .exists(customerComunication.getId())); + } + + @Test + public void testSaveCustomerComunicationWithoutSubcontratedTaskData() + throws InstanceNotFoundException { + SubcontractorComunication subcontractorComunication = createValidSubcontractorComunication(); + subcontractorComunication.setSubcontractedTaskData(null); + try { + subcontractorComunicationDAO.save(subcontractorComunication); + fail("It should throw an exception"); + } catch (ValidationException e) { + // Ok + } + } + +} \ No newline at end of file diff --git a/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml b/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml index c6ad39bd0..ca7a4fd12 100644 --- a/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml +++ b/libreplan-business/src/test/resources/libreplan-business-spring-config-test.xml @@ -87,6 +87,9 @@ org/libreplan/business/planner/entities/AdvanceConsolidations.hbm.xml + + org/libreplan/business/planner/entities/SubcontractorComunication.hbm.xml + org/libreplan/business/scenarios/entities/Scenarios.hbm.xml diff --git a/libreplan-webapp/src/test/resources/libreplan-webapp-spring-config-test.xml b/libreplan-webapp/src/test/resources/libreplan-webapp-spring-config-test.xml index 1072a2bcb..d440fb211 100644 --- a/libreplan-webapp/src/test/resources/libreplan-webapp-spring-config-test.xml +++ b/libreplan-webapp/src/test/resources/libreplan-webapp-spring-config-test.xml @@ -84,6 +84,9 @@ org/libreplan/business/planner/entities/AdvanceConsolidations.hbm.xml + + org/libreplan/business/planner/entities/SubcontractorComunication.hbm.xml + org/libreplan/business/scenarios/entities/Scenarios.hbm.xml