ItEr37S12CUAdministracionCategoriaCosteItEr36S14: basic implementation of the entity ResourcesCostCategoryAssignment
Implemented the entity, its DAO and a basic test.
This commit is contained in:
parent
ca986edb17
commit
ff2e2c5b0c
5 changed files with 234 additions and 0 deletions
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.costcategories.daos;
|
||||
|
||||
import org.navalplanner.business.common.daos.IGenericDAO;
|
||||
import org.navalplanner.business.costcategories.entities.ResourcesCostCategoryAssignment;
|
||||
|
||||
/**
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
*/
|
||||
public interface IResourcesCostCategoryAssignmentDAO extends IGenericDAO<ResourcesCostCategoryAssignment, Long> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.costcategories.daos;
|
||||
|
||||
import org.navalplanner.business.common.daos.GenericDAOHibernate;
|
||||
import org.navalplanner.business.costcategories.entities.ResourcesCostCategoryAssignment;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
*/
|
||||
@Repository
|
||||
@Scope(BeanDefinition.SCOPE_SINGLETON)
|
||||
public class ResourcesCostCategoryAssignmentDAO extends
|
||||
GenericDAOHibernate<ResourcesCostCategoryAssignment, Long> implements
|
||||
IResourcesCostCategoryAssignmentDAO {
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.costcategories.entities;
|
||||
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
|
||||
/**
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
*/
|
||||
public class ResourcesCostCategoryAssignment extends BaseEntity {
|
||||
|
||||
@NotNull
|
||||
private LocalDate initDate;
|
||||
|
||||
private LocalDate endDate;
|
||||
|
||||
// Default constructor, needed by Hibernate
|
||||
protected ResourcesCostCategoryAssignment() {
|
||||
|
||||
}
|
||||
|
||||
public static ResourcesCostCategoryAssignment create() {
|
||||
return (ResourcesCostCategoryAssignment) create(new ResourcesCostCategoryAssignment());
|
||||
}
|
||||
|
||||
public LocalDate getInitDate() {
|
||||
return initDate;
|
||||
}
|
||||
|
||||
public void setInitDate(LocalDate initDate) {
|
||||
this.initDate = initDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
}
|
||||
|
|
@ -61,4 +61,17 @@
|
|||
|
||||
</class>
|
||||
|
||||
<!-- ResourcesCostCategoryAssignment -->
|
||||
<class name="ResourcesCostCategoryAssignment" table="RESOURCES_COST_CATEGORY_ASSIGNMENT">
|
||||
<id name="id" type="long" access="property">
|
||||
<generator class="hilo">
|
||||
<param name="max_lo">100</param>
|
||||
</generator>
|
||||
</id>
|
||||
<version name="version" access="property" type="long" />
|
||||
|
||||
<property name="initDate" type="org.joda.time.contrib.hibernate.PersistentLocalDate"/>
|
||||
|
||||
<property name="endDate" type="org.joda.time.contrib.hibernate.PersistentLocalDate"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.test.costcategories.daos;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.navalplanner.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE;
|
||||
import static org.navalplanner.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.costcategories.daos.IResourcesCostCategoryAssignmentDAO;
|
||||
import org.navalplanner.business.costcategories.entities.ResourcesCostCategoryAssignment;
|
||||
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;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { BUSINESS_SPRING_CONFIG_FILE,
|
||||
BUSINESS_SPRING_CONFIG_TEST_FILE })
|
||||
/**
|
||||
* Test for {@ResourcesCostCategoryDAO}
|
||||
*
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
*
|
||||
*/
|
||||
@Transactional
|
||||
public class ResourcesCostCategoryAssignmentDAOTest {
|
||||
|
||||
@Autowired
|
||||
IResourcesCostCategoryAssignmentDAO resourcesCostCategoryAssignmentDAO;
|
||||
|
||||
@Test
|
||||
public void testInSpringContainer() {
|
||||
assertNotNull(resourcesCostCategoryAssignmentDAO);
|
||||
}
|
||||
|
||||
private ResourcesCostCategoryAssignment createValidResourcesCostCategoryAssignment() {
|
||||
ResourcesCostCategoryAssignment assignment = ResourcesCostCategoryAssignment.create();
|
||||
assignment.setInitDate(new LocalDate());
|
||||
return assignment;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveResourcesCostCategoryAssignment() {
|
||||
ResourcesCostCategoryAssignment assignment = createValidResourcesCostCategoryAssignment();
|
||||
resourcesCostCategoryAssignmentDAO.save(assignment);
|
||||
assertTrue(assignment.getId() != null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveResourcesCostCategoryAssignment() throws InstanceNotFoundException {
|
||||
ResourcesCostCategoryAssignment assignment = createValidResourcesCostCategoryAssignment();
|
||||
resourcesCostCategoryAssignmentDAO.save(assignment);
|
||||
resourcesCostCategoryAssignmentDAO.remove(assignment.getId());
|
||||
assertFalse(resourcesCostCategoryAssignmentDAO.exists(assignment.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListResourcesCostCategoryAssignments() {
|
||||
int previous = resourcesCostCategoryAssignmentDAO.list(ResourcesCostCategoryAssignment.class).size();
|
||||
ResourcesCostCategoryAssignment assignment = createValidResourcesCostCategoryAssignment();
|
||||
resourcesCostCategoryAssignmentDAO.save(assignment);
|
||||
List<ResourcesCostCategoryAssignment> list = resourcesCostCategoryAssignmentDAO.list(ResourcesCostCategoryAssignment.class);
|
||||
assertEquals(previous + 1, list.size());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue