DocumentProjectFetcher implements Serializable { public JavaRDD<AffMatchDocumentProject> fetchDocumentProjects() { JavaRDD<AffMatchDocumentProject> firstDocumentProjects = firstDocumentProjectReader.readDocumentProjects(sparkContext, firstDocProjPath); JavaRDD<AffMatchDocumentProject> secondDocumentProjects = secondDocumentProjectReader.readDocumentProjects(sparkContext, secondDocProjPath); JavaRDD<AffMatchDocumentProject> mergedDocumentProjects = documentProjectMerger.merge(firstDocumentProjects, secondDocumentProjects); return mergedDocumentProjects; }  JavaRDD<AffMatchDocumentProject> fetchDocumentProjects(); void setFirstDocumentProjectReader(DocumentProjectReader firstDocumentProjectReader); void setSecondDocumentProjectReader(DocumentProjectReader secondDocumentProjectReader); void setDocumentProjectMerger(DocumentProjectMerger documentProjectMerger); void setSparkContext(JavaSparkContext sparkContext); void setFirstDocProjPath(String firstDocProjPath); void setSecondDocProjPath(String secondDocProjPath);  }
@Test public void fetchDocumentProjects() { when(firstDocumentProjectReader.readDocumentProjects(sparkContext, firstDocProjPath)).thenReturn(firstDocumentProjects); when(secondDocumentProjectReader.readDocumentProjects(sparkContext, secondDocProjPath)).thenReturn(secondDocumentProjects); when(documentProjectMerger.merge(firstDocumentProjects, secondDocumentProjects)).thenReturn(mergedDocumentProjects); JavaRDD<AffMatchDocumentProject> retDocumentProjects = documentProjectFetcher.fetchDocumentProjects(); assertTrue(retDocumentProjects == mergedDocumentProjects); verify(firstDocumentProjectReader).readDocumentProjects(sparkContext, firstDocProjPath); verify(secondDocumentProjectReader).readDocumentProjects(sparkContext, secondDocProjPath); verify(documentProjectMerger).merge(firstDocumentProjects, secondDocumentProjects); }