use of edu.harvard.iq.dataverse.DataverseServiceBean in project dataverse by IQSS.
the class MoveDataverseCommandTest method setUp.
@Before
public void setUp() {
root = new Dataverse();
root.setName("root");
root.setId(1l);
childA = new Dataverse();
childA.setName("childA");
childA.setId(2l);
childB = new Dataverse();
childB.setName("childB");
childB.setId(3l);
grandchildAA = new Dataverse();
grandchildAA.setName("grandchildAA");
grandchildAA.setId(4l);
childA.setOwner(root);
childB.setOwner(root);
grandchildAA.setOwner(childA);
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public DataverseServiceBean dataverses() {
return new DataverseServiceBean() {
@Override
public Dataverse save(Dataverse dataverse) {
// no-op. The superclass accesses databases which we don't have.
return dataverse;
}
};
}
});
}
use of edu.harvard.iq.dataverse.DataverseServiceBean in project dataverse by IQSS.
the class MoveDatasetCommandTest method setUp.
@Before
public void setUp() {
auth = makeAuthenticatedUser("Super", "User");
auth.setSuperuser(true);
nobody = makeAuthenticatedUser("Nick", "Nobody");
nobody.setSuperuser(false);
root = new Dataverse();
root.setName("root");
root.setId(1l);
root.setPublicationDate(new Timestamp(new Date().getTime()));
childA = new Dataverse();
childA.setName("childA");
childA.setId(2l);
childA.setPublicationDate(new Timestamp(new Date().getTime()));
childB = new Dataverse();
childB.setName("childB");
childB.setId(3l);
childB.setPublicationDate(new Timestamp(new Date().getTime()));
grandchildAA = new Dataverse();
grandchildAA.setName("grandchildAA");
grandchildAA.setId(4l);
grandchildAA.setPublicationDate(new Timestamp(new Date().getTime()));
childDraft = new Dataverse();
childDraft.setName("childDraft");
childDraft.setId(5l);
grandchildBB = new Dataverse();
grandchildBB.setName("grandchildBB");
grandchildBB.setId(6l);
grandchildBB.setPublicationDate(new Timestamp(new Date().getTime()));
moved = new Dataset();
moved.setOwner(root);
moved.setPublicationDate(new Timestamp(new Date().getTime()));
moved.setId(1l);
movedResponses = new Dataset();
movedResponses.setOwner(root);
movedResponses.setPublicationDate(new Timestamp(new Date().getTime()));
movedResponses.setId(2l);
childA.setOwner(root);
childB.setOwner(root);
grandchildAA.setOwner(childA);
grandchildBB.setOwner(childA);
childDraft.setOwner(childA);
gbA = new Guestbook();
gbA.setId(1l);
gbB = new Guestbook();
gbB.setId(2l);
gbC = new Guestbook();
gbC.setId(3l);
moved.setGuestbook(gbA);
movedResponses.setGuestbook(gbA);
GuestbookResponse gbResp = new GuestbookResponse();
gbResp.setGuestbook(gbA);
gbResp.setDataset(movedResponses);
List<Guestbook> includeA = new ArrayList();
includeA.add(gbA);
includeA.add(gbB);
grandchildAA.setGuestbooks(includeA);
List<Guestbook> notIncludeA = new ArrayList();
notIncludeA.add(gbC);
notIncludeA.add(gbB);
childB.setGuestbooks(notIncludeA);
List<Guestbook> none = new ArrayList();
root.setGuestbooks(none);
grandchildBB.setGuestbooks(none);
grandchildBB.setGuestbookRoot(false);
childA.setGuestbooks(includeA);
testEngine = new TestDataverseEngine(new TestCommandContext() {
@Override
public DataverseServiceBean dataverses() {
return new DataverseServiceBean() {
@Override
public Dataverse save(Dataverse dataverse) {
// no-op. The superclass accesses databases which we don't have.
return dataverse;
}
};
}
@Override
public GuestbookServiceBean guestbooks() {
return new GuestbookServiceBean() {
@Override
public Long findCountResponsesForGivenDataset(Long guestbookId, Long datasetId) {
// We're going to fake a response for a dataset with responses
if (datasetId == 1) {
return new Long(0);
} else {
return new Long(1);
}
}
};
}
@Override
public IndexServiceBean index() {
return new IndexServiceBean() {
@Override
public Future<String> indexDataset(Dataset dataset, boolean doNormalSolrDocCleanUp) {
return null;
}
};
}
@Override
public EntityManager em() {
return new MockEntityManager() {
};
}
});
}
use of edu.harvard.iq.dataverse.DataverseServiceBean in project dataverse by IQSS.
the class UpdatePermissionRootCommandTest method setUp.
@Before
public void setUp() {
mockBean = new DataverseServiceBean() {
@Override
public Dataverse save(Dataverse dv) {
serviceBeanCalled = true;
return dv;
}
};
testCommandContext = new TestCommandContext() {
@Override
public DataverseServiceBean dataverses() {
return mockBean;
}
};
serviceBeanCalled = false;
}
Aggregations