Test for OrderImporterMPXJ and needed files

Added external needed project files. One .mpp and one .planner.

FEA: ItEr77S05BasicProjectImport
This commit is contained in:
Alba Carro 2012-08-24 23:54:30 +02:00 committed by Manuel Rego Casasnovas
parent 21a8d1cc68
commit 5ffdfeec20
3 changed files with 149 additions and 0 deletions

View file

@ -0,0 +1,109 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2012 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 <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.test.orders.imports;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.libreplan.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE;
import static org.libreplan.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.libreplan.business.orders.imports.ImportData;
import org.libreplan.business.orders.imports.OrderImporter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Tests for {@link OrderImport}. <br />
*
* @author Alba Carro Pérez <alba.carro@gmail.com>
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { BUSINESS_SPRING_CONFIG_FILE,
BUSINESS_SPRING_CONFIG_TEST_FILE })
public class OrderImporterTest {
@Autowired
private OrderImporter orderImporter;
@Test
public void testCreatingImportDataFromMPPFile() {
String filename = System.getProperty("user.dir")
+ "/../scripts/mpxj-import/T1R1FCT2R2.mpp";
InputStream file;
try {
file = new FileInputStream(filename);
ImportData importData = orderImporter.getImportData(file, filename);
assertEquals(importData.name, "T1R1FCT2R2");
assertEquals(importData.tasks.size(), 2);
assertEquals(importData.tasks.get(0).name, "Tarea1");
assertEquals(importData.tasks.get(1).name, "Tarea2");
assertEquals(importData.tasks.get(0).children.size(), 0);
assertEquals(importData.tasks.get(1).children.size(), 0);
} catch (FileNotFoundException e) {
assertTrue(false);
}
}
@Test
public void testCreatingImportDataFromPlannerFile() {
String filename = System.getProperty("user.dir")
+ "/../scripts/mpxj-import/T1R1FCT2R2.planner";
InputStream file;
try {
file = new FileInputStream(filename);
ImportData importData = orderImporter.getImportData(file, filename);
assertEquals(importData.tasks.size(), 2);
assertEquals(importData.tasks.get(0).name, "Tarea1");
assertEquals(importData.tasks.get(1).name, "Tarea2");
assertEquals(importData.tasks.get(0).children.size(), 0);
assertEquals(importData.tasks.get(1).children.size(), 0);
} catch (FileNotFoundException e) {
assertTrue(false);
}
}
}

Binary file not shown.

View file

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<project name="" company="" manager="" phase="" project-start="20120803T000000Z" mrproject-version="2" calendar="1">
<properties/>
<phases/>
<calendars>
<day-types>
<day-type id="0" name="Working" description="A default working day"/>
<day-type id="1" name="Nonworking" description="A default non working day"/>
<day-type id="2" name="Use base" description="Use day from base calendar"/>
</day-types>
<calendar id="1" name="Default">
<default-week mon="0" tue="0" wed="0" thu="0" fri="0" sat="1" sun="1"/>
<overridden-day-types>
<overridden-day-type id="0">
<interval start="0800" end="1200"/>
<interval start="1300" end="1700"/>
</overridden-day-type>
</overridden-day-types>
<days/>
</calendar>
</calendars>
<tasks>
<task id="1" name="Tarea1" note="" work="201600" start="20120803T000000Z" end="20120813T170000Z" work-start="20120803T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work"/>
<task id="2" name="Tarea2" note="" work="288000" start="20120805T000000Z" end="20120817T170000Z" work-start="20120806T080000Z" percent-complete="0" priority="0" type="normal" scheduling="fixed-work">
<constraint type="must-start-on" time="20120805T000000Z"/>
<predecessors>
<predecessor id="1" predecessor-id="1" type="FS"/>
</predecessors>
</task>
</tasks>
<resource-groups/>
<resources>
<resource id="1" name="Recurso1" short-name="R1" type="1" units="0" email="" note="" std-rate="0"/>
<resource id="2" name="Recurso2" short-name="R2" type="2" units="0" email="" note="" std-rate="0"/>
</resources>
<allocations>
<allocation task-id="1" resource-id="1" units="100"/>
<allocation task-id="2" resource-id="2" units="100"/>
</allocations>
</project>