@Test public void testEquivalence() throws Exception { final Date now = new Date(); Map<String, String> parameters = new HashMap<>(); parameters.put("param", "value"); parameters.put("param-2", "value-2"); final JaxbIncident dto = new JaxbIncident(new IncidentImpl( 1, 2, "service", "localhost", now, Severity.FAILURE, "code", Arrays.asList(tuple("detail-1", "value-1"), tuple("detail-2", "detail-2")), parameters)); final Incident incident = dto.toIncident(); run(Incident.class, new Incident() { @Override public long getId() { assertEquals("id transferred", 1L, incident.getId()); return 0; } @Override public long getJobId() { assertEquals("jobId transferred", 2L, incident.getJobId()); return 0; } @Override public String getServiceType() { assertEquals("serviceType transferred", "service", incident.getServiceType()); return null; } @Override public String getProcessingHost() { assertEquals("processingHost transferred", "localhost", incident.getProcessingHost()); return null; } @Override public Date getTimestamp() { assertEquals("timestamp transferred", now, incident.getTimestamp()); return null; } @Override public Severity getSeverity() { assertEquals("severity transferred", Severity.FAILURE, incident.getSeverity()); return null; } @Override public String getCode() { assertEquals("code transferred", "code", incident.getCode()); return null; } @Override public List<Tuple<String, String>> getDetails() { assertEquals("details transferred", Arrays.asList(tuple("detail-1", "value-1"), tuple("detail-2", "detail-2")), incident.getDetails()); return null; } @Override public Map<String, String> getDescriptionParameters() { Map<String, String> parameters = new HashMap<>(); parameters.put("param", "value"); parameters.put("param-2", "value-2"); assertEquals("decriptionParameters transferred", parameters, incident.getDescriptionParameters()); return null; } }); }
public Incident toIncident() { return new IncidentImpl(id, jobId, serviceType, processingHost, timestamp, severity, code, mlist(nullToNil(details)).map(JaxbIncidentDetail.toDetailFn).value(), mlist( nullToNil(descriptionParameters)).foldl(new HashMap<>(), new Function2<Map<String, String>, Param, Map<String, String>>() { @Override public Map<String, String> apply(Map<String, String> sum, Param param) { sum.put(param.getName(), param.getValue()); return sum; } })); }
JaxbIncident { public Incident toIncident() { return new IncidentImpl(id, jobId, serviceType, processingHost, timestamp, severity, code, mlist(nullToNil(details)).map(JaxbIncidentDetail.toDetailFn).value(), mlist( nullToNil(descriptionParameters)).foldl(new HashMap<>(), new Function2<Map<String, String>, Param, Map<String, String>>() { @Override public Map<String, String> apply(Map<String, String> sum, Param param) { sum.put(param.getName(), param.getValue()); return sum; } })); } }
JaxbIncident { public Incident toIncident() { return new IncidentImpl(id, jobId, serviceType, processingHost, timestamp, severity, code, mlist(nullToNil(details)).map(JaxbIncidentDetail.toDetailFn).value(), mlist( nullToNil(descriptionParameters)).foldl(new HashMap<>(), new Function2<Map<String, String>, Param, Map<String, String>>() { @Override public Map<String, String> apply(Map<String, String> sum, Param param) { sum.put(param.getName(), param.getValue()); return sum; } })); } JaxbIncident();  JaxbIncident(Incident incident); }
JaxbIncident { public Incident toIncident() { return new IncidentImpl(id, jobId, serviceType, processingHost, timestamp, severity, code, mlist(nullToNil(details)).map(JaxbIncidentDetail.toDetailFn).value(), mlist( nullToNil(descriptionParameters)).foldl(new HashMap<>(), new Function2<Map<String, String>, Param, Map<String, String>>() { @Override public Map<String, String> apply(Map<String, String> sum, Param param) { sum.put(param.getName(), param.getValue()); return sum; } })); } JaxbIncident();  JaxbIncident(Incident incident); Incident toIncident(); }
JaxbIncident { public Incident toIncident() { return new IncidentImpl(id, jobId, serviceType, processingHost, timestamp, severity, code, mlist(nullToNil(details)).map(JaxbIncidentDetail.toDetailFn).value(), mlist( nullToNil(descriptionParameters)).foldl(new HashMap<>(), new Function2<Map<String, String>, Param, Map<String, String>>() { @Override public Map<String, String> apply(Map<String, String> sum, Param param) { sum.put(param.getName(), param.getValue()); return sum; } })); } JaxbIncident();  JaxbIncident(Incident incident); Incident toIncident(); static final Function<Incident, JaxbIncident> mkFn; static final Function<JaxbIncident, Incident> toIncidentFn; }