Skip to content

Commit

Permalink
Merge pull request LaunchCodeEducation#5 from LaunchCodeEducation/mik…
Browse files Browse the repository at this point in the history
…e-issue-74

Fixed unit test EOL handling
  • Loading branch information
mlambert125 authored Sep 29, 2024
2 parents cb3d1f5 + 5cc2791 commit 75c5667
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
19 changes: 12 additions & 7 deletions src/test/java/org/launchcode/techjobs/oo/AbstractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import static java.lang.System.lineSeparator;

/**
* Created by LaunchCode
Expand Down Expand Up @@ -68,13 +69,17 @@ protected int getJobId(Job job) throws ClassNotFoundException, NoSuchMethodExcep
}

protected String getJobString (Job job) throws NoSuchMethodException, ClassNotFoundException, InvocationTargetException, IllegalAccessException, NoSuchFieldException {
return String.format("\nID: %d\n" +
"Name: %s\n" +
"Employer: %s\n" +
"Location: %s\n" +
"Position Type: %s\n" +
"Core Competency: %s\n", getJobId(job), getJobFieldString(job, "name", true), getJobFieldString(job, "employer", true), getJobFieldString(job, "location", true),
getJobFieldString(job, "positionType", true), getJobFieldString(job, "coreCompetency", true));
return String.format(
lineSeparator() +
"ID: %d" + lineSeparator() +
"Name: %s" + lineSeparator() +
"Employer: %s" + lineSeparator() +
"Location: %s" + lineSeparator() +
"Position Type: %s" + lineSeparator() +
"Core Competency: %s" + lineSeparator(),
getJobId(job), getJobFieldString(job, "name", true), getJobFieldString(job, "employer", true), getJobFieldString(job, "location", true),
getJobFieldString(job, "positionType", true), getJobFieldString(job, "coreCompetency", true)
);
}

}
8 changes: 4 additions & 4 deletions src/test/java/org/launchcode/techjobs/oo/TestTaskFive.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import static java.lang.System.lineSeparator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
Expand All @@ -36,10 +37,9 @@ public void testTestToStringStartsAndEndsWithNewLineExists () throws ClassNotFou
@Test
public void testToStringStartsAndEndsWithNewLine() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
Job job = createJob("Web Developer", "LaunchCode", "StL", "Back-end developer", "Java");
String firstChar = String.valueOf(job.toString().charAt(0));
String lastChar = String.valueOf(job.toString().charAt(job.toString().length()-1));
assertEquals(firstChar, lineSeparator());
assertEquals(lastChar, lineSeparator());

assertTrue(job.toString().startsWith(lineSeparator()));
assertTrue(job.toString().endsWith(lineSeparator()));
}

@Test
Expand Down

0 comments on commit 75c5667

Please sign in to comment.