use of edu.harvard.iq.dataverse.settings.SettingsServiceBean in project dataverse by IQSS.
the class JsonPrinterTest method testDatasetContactOutOfBoxNoPrivacy.
@Test
public void testDatasetContactOutOfBoxNoPrivacy() {
MetadataBlock block = new MetadataBlock();
block.setName("citation");
List<DatasetField> fields = new ArrayList<>();
DatasetField datasetContactField = new DatasetField();
DatasetFieldType datasetContactDatasetFieldType = datasetFieldTypeSvc.findByName("datasetContact");
datasetContactDatasetFieldType.setMetadataBlock(block);
datasetContactField.setDatasetFieldType(datasetContactDatasetFieldType);
List<DatasetFieldCompoundValue> vals = new LinkedList<>();
DatasetFieldCompoundValue val = new DatasetFieldCompoundValue();
val.setParentDatasetField(datasetContactField);
val.setChildDatasetFields(Arrays.asList(constructPrimitive("datasetContactEmail", "foo@bar.com"), constructPrimitive("datasetContactName", "Foo Bar"), constructPrimitive("datasetContactAffiliation", "Bar University")));
vals.add(val);
datasetContactField.setDatasetFieldCompoundValues(vals);
fields.add(datasetContactField);
SettingsServiceBean nullServiceBean = null;
JsonPrinter jsonPrinter = new JsonPrinter(nullServiceBean);
JsonObject jsonObject = jsonPrinter.json(block, fields).build();
assertNotNull(jsonObject);
System.out.println("json: " + JsonUtil.prettyPrint(jsonObject.toString()));
assertEquals("Foo Bar", jsonObject.getJsonArray("fields").getJsonObject(0).getJsonArray("value").getJsonObject(0).getJsonObject("datasetContactName").getString("value"));
assertEquals("Bar University", jsonObject.getJsonArray("fields").getJsonObject(0).getJsonArray("value").getJsonObject(0).getJsonObject("datasetContactAffiliation").getString("value"));
assertEquals("foo@bar.com", jsonObject.getJsonArray("fields").getJsonObject(0).getJsonArray("value").getJsonObject(0).getJsonObject("datasetContactEmail").getString("value"));
JsonObject byBlocks = jsonPrinter.jsonByBlocks(fields).build();
System.out.println("byBlocks: " + JsonUtil.prettyPrint(byBlocks.toString()));
assertEquals("Foo Bar", byBlocks.getJsonObject("citation").getJsonArray("fields").getJsonObject(0).getJsonArray("value").getJsonObject(0).getJsonObject("datasetContactName").getString("value"));
assertEquals("Bar University", byBlocks.getJsonObject("citation").getJsonArray("fields").getJsonObject(0).getJsonArray("value").getJsonObject(0).getJsonObject("datasetContactAffiliation").getString("value"));
assertEquals("foo@bar.com", byBlocks.getJsonObject("citation").getJsonArray("fields").getJsonObject(0).getJsonArray("value").getJsonObject(0).getJsonObject("datasetContactEmail").getString("value"));
}
use of edu.harvard.iq.dataverse.settings.SettingsServiceBean in project dataverse by IQSS.
the class RestrictFileCommandTest method setUp.
@Before
public void setUp() {
dataset = makeDataset();
file = makeDataFile();
engine = new TestDataverseEngine(new TestCommandContext() {
@Override
public SettingsServiceBean settings() {
return new SettingsServiceBean() {
// override for a public install,
// assume false
@Override
public boolean isTrueForKey(SettingsServiceBean.Key key, boolean defaultValue) {
return publicInstall;
}
};
}
});
}
use of edu.harvard.iq.dataverse.settings.SettingsServiceBean in project dataverse by IQSS.
the class DatasetFieldWalker method walk.
/**
* Convenience method to walk over a field.
* @param dsf the field to walk over.
* @param l the listener to execute on {@code dsf}'s values and structure.
*/
public static void walk(DatasetField dsf, Listener l) {
DatasetFieldWalker joe = new DatasetFieldWalker(l);
SettingsServiceBean nullServiceBean = null;
joe.walk(dsf, nullServiceBean);
}
Aggregations