### Question:
JobValidator { private Set<String> validateGracePeriodAndExternalPorts(final Job job) { final Integer gracePeriod = job.getGracePeriod(); if (gracePeriod != null && gracePeriod > 0 && job.hasExternalPorts()) { return singleton("Job has both grace period and static/external ports. External ports will " + "prevent new containers from deploying during the gracePeriod because of port " + "conflicts. Please choose one or the other."); } return emptySet(); } JobValidator();  JobValidator(final boolean shouldValidateJobHash);  JobValidator(final boolean shouldValidateJobHash,
                      final boolean shouldValidateAddCapabilities);  JobValidator(final boolean shouldValidateJobHash,
                      final boolean shouldValidateAddCapabilities,
                      final Set<String> whitelistedCapabilities); Set<String> validate(final Job job);  }### Answer:
@Test public void testValidateGracePeriodAndExternalPorts() throws Exception { final Job noPorts = Json.read(stringFromResource("job-with-no-ports.json"), Job.class); assertThat(validator.validate(noPorts), Matchers.<String>empty()); final Job noExternalPorts = Json.read( stringFromResource("job-with-no-external-ports.json"), Job.class); assertThat(validator.validate(noExternalPorts), Matchers.<String>empty()); final Job externalPorts = Json.read( stringFromResource("job-with-external-ports.json"), Job.class); assertThat(validator.validate(externalPorts), Matchers.<String>empty()); final Job gracePeriod = Json.read( stringFromResource("job-with-grace-period.json"), Job.class); assertThat(validator.validate(gracePeriod), Matchers.<String>empty()); final Job externalPortsAndGracePeriod = Json.read( stringFromResource("job-with-external-ports-and-grace-period.json"), Job.class); assertThat(validator.validate(externalPortsAndGracePeriod), hasItem("Job has both grace period and static/external ports. External ports will " + "prevent new containers from deploying during the gracePeriod because of port " + "conflicts. Please choose one or the other.")); }