Skip to content

Commit

Permalink
Load input files in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
clough committed Nov 24, 2019
1 parent b845ba2 commit a31036f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.commons.cli.*;

import java.io.File;
import java.io.IOException;

public class BomPanelizer {

Expand Down Expand Up @@ -62,6 +63,9 @@ public static void main(String[] args) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("bom-panelizer", options);
}
catch(IOException e ) {
System.out.println(e.getMessage());
}
}

public static void setPanelizerForTesting(Panelizer panelizer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package com.clough42.bom.panelizer.panelizer;

import com.clough42.bom.panelizer.csv.BomFile;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Panelizer {

public Panelizer() {
}

public void panelize(File bomFile, File centroidFile, File panelFile, File outputBomFile, File outputCentroidFile) {
public void panelize(File bomFile, File centroidFile, File panelFile, File outputBomFile, File outputCentroidFile) throws IOException {
System.out.println("bomFile: " + bomFile.getAbsolutePath());
System.out.println("centroidFile: " + centroidFile.getAbsolutePath());
System.out.println("panelFile: " + panelFile.getAbsolutePath());
System.out.println("outputBomFile: " + outputBomFile.getAbsolutePath());
System.out.println("outputCentroidFile: " + outputCentroidFile.getAbsolutePath());

BomFile inputBom = BomFile.load(new FileReader(bomFile));
BomFile inputCentroid = BomFile.load(new FileReader(centroidFile));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public void TearDown() throws Exception {
}

@Test
public void executeMainNoArgs() {
public void executeMainNoArgs() throws IOException {
BomPanelizer.main(null);

verify(mockPanelizer, never()).panelize(any(File.class), any(File.class), any(File.class), any(File.class), any(File.class));
}

@Test
public void executeMainWithArgs() {
public void executeMainWithArgs() throws IOException {
BomPanelizer.main(new String[]{
"-b", testFiles.SAMPLE_BOM_FILENAME,
"-c", testFiles.SAMPLE_PICK_PLACE_FILENAME,
Expand All @@ -53,7 +53,7 @@ public void executeMainWithArgs() {
}

@Test(expected = IllegalArgumentException.class)
public void executeMainWithBadBomFile() {
public void executeMainWithBadBomFile() throws IOException {
BomPanelizer.main(new String[]{
"-b", testFiles.SAMPLE_BOM_FILENAME + "X",
"-c", testFiles.SAMPLE_PICK_PLACE_FILENAME,
Expand All @@ -64,7 +64,7 @@ public void executeMainWithBadBomFile() {
}

@Test(expected = IllegalArgumentException.class)
public void executeMainWithBadCentroidFile() {
public void executeMainWithBadCentroidFile() throws IOException {
BomPanelizer.main(new String[]{
"-b", testFiles.SAMPLE_BOM_FILENAME,
"-c", testFiles.SAMPLE_PICK_PLACE_FILENAME + "X",
Expand All @@ -75,7 +75,7 @@ public void executeMainWithBadCentroidFile() {
}

@Test(expected = IllegalArgumentException.class)
public void executeMainWithBadPanelFile() {
public void executeMainWithBadPanelFile() throws IOException {
BomPanelizer.main(new String[]{
"-b", testFiles.SAMPLE_BOM_FILENAME,
"-c", testFiles.SAMPLE_PICK_PLACE_FILENAME,
Expand All @@ -86,7 +86,7 @@ public void executeMainWithBadPanelFile() {
}

@Test(expected = IllegalArgumentException.class)
public void executeMainWithBadOutputDirectory() {
public void executeMainWithBadOutputDirectory() throws IOException {
BomPanelizer.main(new String[]{
"-b", testFiles.SAMPLE_BOM_FILENAME,
"-c", testFiles.SAMPLE_PICK_PLACE_FILENAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void tearDown() throws IOException {
}

@Test
public void testHappyDay() {
public void testHappyDay() throws IOException {
uut.panelize(
testFiles.SAMPLE_BOM,
testFiles.SAMPLE_PICK_PLACE,
Expand Down

0 comments on commit a31036f

Please sign in to comment.