InferredDocumentProjectConverter implements Serializable { public AffMatchDocumentProject convert(DocumentToProject documentProject) { Preconditions.checkNotNull(documentProject); Preconditions.checkArgument(StringUtils.isNotBlank(documentProject.getDocumentId())); Preconditions.checkArgument(StringUtils.isNotBlank(documentProject.getProjectId())); Preconditions.checkArgument(documentProject.getConfidenceLevel() >= 0 && documentProject.getConfidenceLevel() <= 1); return new AffMatchDocumentProject(documentProject.getDocumentId().toString(), documentProject.getProjectId().toString(), documentProject.getConfidenceLevel()); }  AffMatchDocumentProject convert(DocumentToProject documentProject);  }
@Test(expected = NullPointerException.class) public void convert_null() { converter.convert(null); }
@Test(expected = IllegalArgumentException.class) public void convert_blank_document_id() { converter.convert(new DocumentToProject(" ", projId, 1f, null)); }
@Test(expected = IllegalArgumentException.class) public void convert_blank_project_id() { converter.convert(new DocumentToProject(docId, " ", 1f, null)); }
@Test(expected = IllegalArgumentException.class) public void convert_out_of_right_range_confidence_level() { converter.convert(new DocumentToProject(docId, projId, 2f, null)); }
@Test(expected = IllegalArgumentException.class) public void convert_out_of_left_range_confidence_level() { converter.convert(new DocumentToProject(docId, projId, -1f, null)); }
@Test(expected = IllegalArgumentException.class) public void convert_null_document_id() { converter.convert(new DocumentToProject(null, projId, confidenceLevel, null)); }
@Test(expected = IllegalArgumentException.class) public void convert_null_project_id() { converter.convert(new DocumentToProject(docId, null, confidenceLevel, null)); }
@Test public void convert() { AffMatchDocumentProject result = converter.convert(new DocumentToProject(docId, projId, confidenceLevel, null)); assertEquals(docId, result.getDocumentId()); assertEquals(projId, result.getProjectId()); assertEquals(confidenceLevel, result.getConfidenceLevel(), 0); }