### Question:
NodeFactoryWithDatasetContext implements NodeFactory { @Override public Study createStudy(Study study) { return factory.createStudy(studyForDataset(study)); } NodeFactoryWithDatasetContext(NodeFactory factory, Dataset dataset); @Override Location findLocation(Location location); @Override Season createSeason(String seasonNameLower); @Override Specimen createSpecimen(Interaction interaction, Taxon taxon); @Override Specimen createSpecimen(Study study, Taxon taxon); @Override Specimen createSpecimen(Study study, Taxon taxon, RelTypes... relTypes); @Override Study createStudy(Study study); @Override Study getOrCreateStudy(Study study); @Override Study findStudy(String title); @Override Season findSeason(String seasonName); @Override Location getOrCreateLocation(Location location); @Override void setUnixEpochProperty(Specimen specimen, Date date); @Override Date getUnixEpochProperty(Specimen specimen); @Override List<Environment> getOrCreateEnvironments(Location location, String externalId, String name); @Override List<Environment> addEnvironmentToLocation(Location location, List<Term> terms); @Override Term getOrCreateBodyPart(String externalId, String name); @Override Term getOrCreatePhysiologicalState(String externalId, String name); @Override Term getOrCreateLifeStage(String externalId, String name); @Override TermLookupService getTermLookupService(); @Override AuthorIdResolver getAuthorResolver(); @Override Term getOrCreateBasisOfRecord(String externalId, String name); @Override Dataset getOrCreateDataset(Dataset dataset); @Override Interaction createInteraction(Study study); Dataset getDataset();  }### Answer:
@Test public void createStudy() { NodeFactory factory = Mockito.mock(NodeFactory.class); DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream); NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset); StudyImpl study = new StudyImpl("some title", new DOI("123", "abc"), "some citation"); study.setExternalId("some:id"); factoryWithDS.createStudy(study); ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class); verify(factory).createStudy(argument.capture()); assertEquals("some title", argument.getValue().getTitle()); assertEquals("some citation", argument.getValue().getCitation()); assertEquals("10.123/abc", argument.getValue().getDOI().toString()); assertEquals("some:id", argument.getValue().getExternalId()); }