Skip to content

Commit

Permalink
Code inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles committed Nov 25, 2024
1 parent 54d85cb commit 8aa6a7a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 26 deletions.
1 change: 0 additions & 1 deletion src/main/java/net/sf/mpxj/ProjectFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

import net.sf.mpxj.common.NumberHelper;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/sf/mpxj/explorer/ProjectExplorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

import com.jgoodies.binding.beans.PropertyAdapter;

import net.sf.mpxj.MPXJException;
import net.sf.mpxj.ProjectFile;
import net.sf.mpxj.primavera.PrimaveraPMFileReader;
import net.sf.mpxj.primavera.PrimaveraXERFileReader;
Expand Down Expand Up @@ -278,7 +277,7 @@ private void openAll(File file)
{
updateAndSaveRecents(file);

try (UniversalProjectReader.ProjectReaderProxy proxy = new UniversalProjectReader().getProjectReaderProxy(file);)
try (UniversalProjectReader.ProjectReaderProxy proxy = new UniversalProjectReader().getProjectReaderProxy(file))
{
if (proxy == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.ArrayList;
import java.util.Comparator;

import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/net/sf/mpxj/junit/RateHelperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public class RateHelperTest
ProjectFile file = new ProjectFile();
file.setDefaultCalendar(file.addDefaultBaseCalendar());

Assert.assertEquals(RateHelper.convertToHours(file.getProjectProperties(), new Rate(1, TimeUnit.MINUTES)), 60, 0.0);
Assert.assertEquals(RateHelper.convertToHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS)), 1, 0.0);
Assert.assertEquals(RateHelper.convertToHours(file.getProjectProperties(), new Rate(8, TimeUnit.DAYS)), 1, 0.0);
Assert.assertEquals(RateHelper.convertToHours(file.getProjectProperties(), new Rate(40, TimeUnit.WEEKS)), 1, 0.0);
Assert.assertEquals(RateHelper.convertToHours(file.getProjectProperties(), new Rate(160, TimeUnit.MONTHS)), 1, 0.0);
Assert.assertEquals(RateHelper.convertToHours(file.getProjectProperties(), new Rate(2080, TimeUnit.YEARS)), 1, 0.0);
Assert.assertEquals(60, RateHelper.convertToHours(file.getProjectProperties(), new Rate(1, TimeUnit.MINUTES)), 0.0);
Assert.assertEquals(1, RateHelper.convertToHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS)), 0.0);
Assert.assertEquals(1, RateHelper.convertToHours(file.getProjectProperties(), new Rate(8, TimeUnit.DAYS)), 0.0);
Assert.assertEquals(1, RateHelper.convertToHours(file.getProjectProperties(), new Rate(40, TimeUnit.WEEKS)), 0.0);
Assert.assertEquals(1, RateHelper.convertToHours(file.getProjectProperties(), new Rate(160, TimeUnit.MONTHS)), 0.0);
Assert.assertEquals(1, RateHelper.convertToHours(file.getProjectProperties(), new Rate(2080, TimeUnit.YEARS)), 0.0);
}

/**
Expand All @@ -58,11 +58,11 @@ public class RateHelperTest
ProjectFile file = new ProjectFile();
file.setDefaultCalendar(file.addDefaultBaseCalendar());

Assert.assertEquals(RateHelper.convertFromHours(file.getProjectProperties(), new Rate(60, TimeUnit.HOURS), TimeUnit.MINUTES).getAmount(), 1, 0.0);
Assert.assertEquals(RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.HOURS).getAmount(), 1, 0.0);
Assert.assertEquals(RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.DAYS).getAmount(), 8, 0.0);
Assert.assertEquals(RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.WEEKS).getAmount(), 40, 0.0);
Assert.assertEquals(RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.MONTHS).getAmount(), 160, 0.0);
Assert.assertEquals(RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.YEARS).getAmount(), 2080, 0.0);
Assert.assertEquals(1, RateHelper.convertFromHours(file.getProjectProperties(), new Rate(60, TimeUnit.HOURS), TimeUnit.MINUTES).getAmount(), 0.0);
Assert.assertEquals(1, RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.HOURS).getAmount(), 0.0);
Assert.assertEquals(8, RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.DAYS).getAmount(), 0.0);
Assert.assertEquals(40, RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.WEEKS).getAmount(), 0.0);
Assert.assertEquals(160, RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.MONTHS).getAmount(), 0.0);
Assert.assertEquals(2080, RateHelper.convertFromHours(file.getProjectProperties(), new Rate(1, TimeUnit.HOURS), TimeUnit.YEARS).getAmount(), 0.0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class XerRelationshipLagCalendarTest
@Test public void testProjectDefaultCalendar() throws Exception
{
ProjectFile xml = new PrimaveraXERFileReader().read(MpxjTestData.filePath("ProjectDefaultCalendar.xer"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.PROJECT_DEFAULT);
assertEquals(RelationshipLagCalendar.PROJECT_DEFAULT, xml.getProjectProperties().getRelationshipLagCalendar());
}

/**
Expand All @@ -49,7 +49,7 @@ public class XerRelationshipLagCalendarTest
@Test public void testPredecessorCalendar() throws Exception
{
ProjectFile xml = new PrimaveraXERFileReader().read(MpxjTestData.filePath("PredecessorCalendar.xer"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.PREDECESSOR);
assertEquals(RelationshipLagCalendar.PREDECESSOR, xml.getProjectProperties().getRelationshipLagCalendar());
}

/**
Expand All @@ -58,7 +58,7 @@ public class XerRelationshipLagCalendarTest
@Test public void testSuccessorCalendar() throws Exception
{
ProjectFile xml = new PrimaveraXERFileReader().read(MpxjTestData.filePath("SuccessorCalendar.xer"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.SUCCESSOR);
assertEquals(RelationshipLagCalendar.SUCCESSOR, xml.getProjectProperties().getRelationshipLagCalendar());
}

/**
Expand All @@ -67,6 +67,6 @@ public class XerRelationshipLagCalendarTest
@Test public void testTwentyFourHourCalendar() throws Exception
{
ProjectFile xml = new PrimaveraXERFileReader().read(MpxjTestData.filePath("TwentyFourHourCalendar.xer"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.TWENTY_FOUR_HOUR);
assertEquals(RelationshipLagCalendar.TWENTY_FOUR_HOUR, xml.getProjectProperties().getRelationshipLagCalendar());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class XmlRelationshipLagCalendarTest
@Test public void testProjectDefaultCalendar() throws Exception
{
ProjectFile xml = new PrimaveraPMFileReader().read(MpxjTestData.filePath("ProjectDefaultCalendar.xml"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.PROJECT_DEFAULT);
assertEquals(RelationshipLagCalendar.PROJECT_DEFAULT, xml.getProjectProperties().getRelationshipLagCalendar());
}

/**
Expand All @@ -49,7 +49,7 @@ public class XmlRelationshipLagCalendarTest
@Test public void testPredecessorCalendar() throws Exception
{
ProjectFile xml = new PrimaveraPMFileReader().read(MpxjTestData.filePath("PredecessorCalendar.xml"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.PREDECESSOR);
assertEquals(RelationshipLagCalendar.PREDECESSOR, xml.getProjectProperties().getRelationshipLagCalendar());
}

/**
Expand All @@ -58,7 +58,7 @@ public class XmlRelationshipLagCalendarTest
@Test public void testSuccessorCalendar() throws Exception
{
ProjectFile xml = new PrimaveraPMFileReader().read(MpxjTestData.filePath("SuccessorCalendar.xml"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.SUCCESSOR);
assertEquals(RelationshipLagCalendar.SUCCESSOR, xml.getProjectProperties().getRelationshipLagCalendar());
}

/**
Expand All @@ -67,6 +67,6 @@ public class XmlRelationshipLagCalendarTest
@Test public void testTwentyFourHourCalendar() throws Exception
{
ProjectFile xml = new PrimaveraPMFileReader().read(MpxjTestData.filePath("TwentyFourHourCalendar.xml"));
assertEquals(xml.getProjectProperties().getRelationshipLagCalendar(), RelationshipLagCalendar.TWENTY_FOUR_HOUR);
assertEquals(RelationshipLagCalendar.TWENTY_FOUR_HOUR, xml.getProjectProperties().getRelationshipLagCalendar());
}
}
4 changes: 2 additions & 2 deletions src/test/java/net/sf/mpxj/junit/legacy/BasicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ public class BasicTest

task1.addTask();
List<Task> children = task1.getChildTasks();
assertEquals(children.size(), 2);
assertEquals(2, children.size());

List<Task> toplevel = file.getChildTasks();
assertEquals(toplevel.size(), 1);
assertEquals(1, toplevel.size());
}

/**
Expand Down

0 comments on commit 8aa6a7a

Please sign in to comment.