@Test public void shouldValidateRefrigeratorProblemsIfFunctioningCorrectlySinceLastVisitIsFalse() throws Exception { Long facilityVisitId = 5L; Reading temperature = new Reading("32.4", false); Reading functioningCorrectly = new Reading("N", false); Reading lowAlarmEvents = new Reading("2", false); Reading highAlarmEvents = new Reading("", true); Reading problemSinceLastTime = new Reading("Y", false); RefrigeratorProblem problems = mock(RefrigeratorProblem.class); String notes = "Notes"; Long facilityId = 2L; RefrigeratorReading expectedReading = new RefrigeratorReading(new Refrigerator("brand", "model", "serial number", facilityId, true), facilityVisitId, 32.4F, "N", 2, null, "Y", problems, notes); RefrigeratorReadingDTO refrigeratorReadingDTO = new RefrigeratorReadingDTO(new Refrigerator("brand", "model", "serial number", facilityId, true), facilityVisitId, temperature, functioningCorrectly, lowAlarmEvents, highAlarmEvents, problemSinceLastTime, problems, notes); RefrigeratorReading refrigeratorReading = refrigeratorReadingDTO.transform(); assertThat(refrigeratorReading, is(expectedReading)); verify(problems).validate(); }
public RefrigeratorReading transform() { refrigerator.setModifiedBy(this.modifiedBy); refrigerator.setCreatedBy(this.createdBy); refrigerator.validate(); if ("N".equalsIgnoreCase(functioningCorrectly.getEffectiveValue())) { problems.validate(); } else { problems = null; } RefrigeratorReading reading = new RefrigeratorReading(this.refrigerator, this.facilityVisitId, this.temperature.parseFloat(), this.functioningCorrectly.getEffectiveValue(), this.lowAlarmEvents.parsePositiveInt(), this.highAlarmEvents.parsePositiveInt(), this.problemSinceLastTime.getEffectiveValue(), this.problems, this.notes); reading.setCreatedBy(this.createdBy); reading.setModifiedBy(this.modifiedBy); return reading; }
RefrigeratorReadingDTO extends BaseModel { public RefrigeratorReading transform() { refrigerator.setModifiedBy(this.modifiedBy); refrigerator.setCreatedBy(this.createdBy); refrigerator.validate(); if ("N".equalsIgnoreCase(functioningCorrectly.getEffectiveValue())) { problems.validate(); } else { problems = null; } RefrigeratorReading reading = new RefrigeratorReading(this.refrigerator, this.facilityVisitId, this.temperature.parseFloat(), this.functioningCorrectly.getEffectiveValue(), this.lowAlarmEvents.parsePositiveInt(), this.highAlarmEvents.parsePositiveInt(), this.problemSinceLastTime.getEffectiveValue(), this.problems, this.notes); reading.setCreatedBy(this.createdBy); reading.setModifiedBy(this.modifiedBy); return reading; } }
RefrigeratorReadingDTO extends BaseModel { public RefrigeratorReading transform() { refrigerator.setModifiedBy(this.modifiedBy); refrigerator.setCreatedBy(this.createdBy); refrigerator.validate(); if ("N".equalsIgnoreCase(functioningCorrectly.getEffectiveValue())) { problems.validate(); } else { problems = null; } RefrigeratorReading reading = new RefrigeratorReading(this.refrigerator, this.facilityVisitId, this.temperature.parseFloat(), this.functioningCorrectly.getEffectiveValue(), this.lowAlarmEvents.parsePositiveInt(), this.highAlarmEvents.parsePositiveInt(), this.problemSinceLastTime.getEffectiveValue(), this.problems, this.notes); reading.setCreatedBy(this.createdBy); reading.setModifiedBy(this.modifiedBy); return reading; }  }
RefrigeratorReadingDTO extends BaseModel { public RefrigeratorReading transform() { refrigerator.setModifiedBy(this.modifiedBy); refrigerator.setCreatedBy(this.createdBy); refrigerator.validate(); if ("N".equalsIgnoreCase(functioningCorrectly.getEffectiveValue())) { problems.validate(); } else { problems = null; } RefrigeratorReading reading = new RefrigeratorReading(this.refrigerator, this.facilityVisitId, this.temperature.parseFloat(), this.functioningCorrectly.getEffectiveValue(), this.lowAlarmEvents.parsePositiveInt(), this.highAlarmEvents.parsePositiveInt(), this.problemSinceLastTime.getEffectiveValue(), this.problems, this.notes); reading.setCreatedBy(this.createdBy); reading.setModifiedBy(this.modifiedBy); return reading; }  RefrigeratorReading transform(); }
RefrigeratorReadingDTO extends BaseModel { public RefrigeratorReading transform() { refrigerator.setModifiedBy(this.modifiedBy); refrigerator.setCreatedBy(this.createdBy); refrigerator.validate(); if ("N".equalsIgnoreCase(functioningCorrectly.getEffectiveValue())) { problems.validate(); } else { problems = null; } RefrigeratorReading reading = new RefrigeratorReading(this.refrigerator, this.facilityVisitId, this.temperature.parseFloat(), this.functioningCorrectly.getEffectiveValue(), this.lowAlarmEvents.parsePositiveInt(), this.highAlarmEvents.parsePositiveInt(), this.problemSinceLastTime.getEffectiveValue(), this.problems, this.notes); reading.setCreatedBy(this.createdBy); reading.setModifiedBy(this.modifiedBy); return reading; }  RefrigeratorReading transform();  }