Search in sources :

Example 1 with SystemConfig

use of edu.harvard.iq.dataverse.util.SystemConfig in project dataverse by IQSS.

the class UpdateDatasetThumbnailCommandTest method setUp.

@Before
public void setUp() {
    dataset = new Dataset();
    testEngine = new TestDataverseEngine(new TestCommandContext() {

        @Override
        public DataFileServiceBean files() {
            return new DataFileServiceBean() {

                @Override
                public DataFile find(Object object) {
                    if (object == unfindableFile) {
                        return null;
                    } else if (object == thumbnailUnexpectedlyAbsent) {
                        return new DataFile();
                    } else {
                        return null;
                    }
                }
            };
        }

        @Override
        public DatasetServiceBean datasets() {
            return new DatasetServiceBean() {

                @Override
                public Dataset setDatasetFileAsThumbnail(Dataset dataset, DataFile datasetFileThumbnailToSwitchTo) {
                    return dataset;
                }
            };
        }

        @Override
        public SystemConfig systemConfig() {
            return new SystemConfig() {

                @Override
                public String getDataverseSiteUrl() {
                    return "https://dataverse.example.edu";
                }
            };
        }
    });
}
Also used : DataFile(edu.harvard.iq.dataverse.DataFile) SystemConfig(edu.harvard.iq.dataverse.util.SystemConfig) TestCommandContext(edu.harvard.iq.dataverse.engine.TestCommandContext) DataFileServiceBean(edu.harvard.iq.dataverse.DataFileServiceBean) Dataset(edu.harvard.iq.dataverse.Dataset) DatasetServiceBean(edu.harvard.iq.dataverse.DatasetServiceBean) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) Before(org.junit.Before)

Example 2 with SystemConfig

use of edu.harvard.iq.dataverse.util.SystemConfig in project dataverse by IQSS.

the class CreatePrivateUrlCommandTest method setUp.

@Before
public void setUp() {
    dataset = new Dataset();
    testEngine = new TestDataverseEngine(new TestCommandContext() {

        @Override
        public PrivateUrlServiceBean privateUrl() {
            return new PrivateUrlServiceBean() {

                @Override
                public PrivateUrl getPrivateUrlFromDatasetId(long datasetId) {
                    if (datasetId == privateUrlAlreadyExists) {
                        Dataset dataset = new Dataset();
                        dataset.setId(privateUrlAlreadyExists);
                        String token = null;
                        PrivateUrlUser privateUrlUser = new PrivateUrlUser(datasetId);
                        RoleAssignment roleAssignment = new RoleAssignment(null, privateUrlUser, dataset, token);
                        return new PrivateUrl(roleAssignment, dataset, "FIXME");
                    } else if (datasetId == latestVersionIsNotDraft) {
                        return null;
                    } else {
                        return null;
                    }
                }
            };
        }

        @Override
        public DataverseRoleServiceBean roles() {
            return new DataverseRoleServiceBean() {

                @Override
                public DataverseRole findBuiltinRoleByAlias(String alias) {
                    return new DataverseRole();
                }

                @Override
                public RoleAssignment save(RoleAssignment assignment) {
                    // no-op
                    return assignment;
                }
            };
        }

        @Override
        public SystemConfig systemConfig() {
            return new SystemConfig() {

                @Override
                public String getDataverseSiteUrl() {
                    return "https://dataverse.example.edu";
                }
            };
        }
    });
}
Also used : DataverseRoleServiceBean(edu.harvard.iq.dataverse.DataverseRoleServiceBean) SystemConfig(edu.harvard.iq.dataverse.util.SystemConfig) TestCommandContext(edu.harvard.iq.dataverse.engine.TestCommandContext) PrivateUrl(edu.harvard.iq.dataverse.privateurl.PrivateUrl) Dataset(edu.harvard.iq.dataverse.Dataset) PrivateUrlUser(edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser) RoleAssignment(edu.harvard.iq.dataverse.RoleAssignment) PrivateUrlServiceBean(edu.harvard.iq.dataverse.privateurl.PrivateUrlServiceBean) TestDataverseEngine(edu.harvard.iq.dataverse.engine.TestDataverseEngine) DataverseRole(edu.harvard.iq.dataverse.authorization.DataverseRole) Before(org.junit.Before)

Aggregations

Dataset (edu.harvard.iq.dataverse.Dataset)2 TestCommandContext (edu.harvard.iq.dataverse.engine.TestCommandContext)2 TestDataverseEngine (edu.harvard.iq.dataverse.engine.TestDataverseEngine)2 SystemConfig (edu.harvard.iq.dataverse.util.SystemConfig)2 Before (org.junit.Before)2 DataFile (edu.harvard.iq.dataverse.DataFile)1 DataFileServiceBean (edu.harvard.iq.dataverse.DataFileServiceBean)1 DatasetServiceBean (edu.harvard.iq.dataverse.DatasetServiceBean)1 DataverseRoleServiceBean (edu.harvard.iq.dataverse.DataverseRoleServiceBean)1 RoleAssignment (edu.harvard.iq.dataverse.RoleAssignment)1 DataverseRole (edu.harvard.iq.dataverse.authorization.DataverseRole)1 PrivateUrlUser (edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser)1 PrivateUrl (edu.harvard.iq.dataverse.privateurl.PrivateUrl)1 PrivateUrlServiceBean (edu.harvard.iq.dataverse.privateurl.PrivateUrlServiceBean)1