use of org.motechproject.mds.dto.RestOptionsDto in project motech by motech.
the class RestIgnoreProcessorTest method shouldProperlyDiscoverRestIgnoredFields.
@Test
public void shouldProperlyDiscoverRestIgnoredFields() throws Exception {
RestOptionsDto restOptionsDto = new RestOptionsDto();
List<FieldDto> fields = mockEntityFields();
processor.setClazz(AnotherSample.class);
processor.setFields(fields);
processor.setRestOptions(restOptionsDto);
processor.execute(bundle, schemaHolder);
// entity fields + auto generated fields
Assert.assertEquals(7, processor.getProcessingResult().getFieldNames().size());
// @RestIgnore annotated
Assert.assertFalse(processor.getProcessingResult().containsField("modificationDate"));
Assert.assertFalse(processor.getProcessingResult().containsField("restIgnoreBoolean"));
// not annotated, regular fields
Assert.assertTrue(processor.getProcessingResult().containsField("anotherInt"));
Assert.assertTrue(processor.getProcessingResult().containsField("anotherString"));
}
use of org.motechproject.mds.dto.RestOptionsDto in project motech by motech.
the class Entity method updateRestOptions.
protected void updateRestOptions(AdvancedSettingsDto advancedSettings) {
RestOptionsDto dto = advancedSettings.getRestOptions();
updateRestOptions(dto);
}
use of org.motechproject.mds.dto.RestOptionsDto in project motech by motech.
the class LookupProcessorTest method shouldNotUpdateRestExposedValueForLookupsThatHaveThatModifiedByUser.
@Test
public void shouldNotUpdateRestExposedValueForLookupsThatHaveThatModifiedByUser() throws Exception {
when(paranamer.lookupParameterNames(getTestMethodExposedViaRest())).thenReturn(argNames);
AdvancedSettingsDto advanced = mock(AdvancedSettingsDto.class);
RestOptionsDto restOptions = mock(RestOptionsDto.class);
when(schemaHolder.getAdvancedSettings(TEST_CLASS_NAME)).thenReturn(advanced);
when(advanced.getRestOptions()).thenReturn(restOptions);
when(restOptions.isModifiedByUser()).thenReturn(true);
EntityProcessorOutput eop = mockEntityProcessorOutput(new EntityDto(TestClass.class.getName()), Arrays.asList(new FieldDto("aaa", "bbb", TypeDto.STRING)));
lookupProcessor.setEntityProcessingResult(Arrays.asList(eop));
Method method = getTestMethodExposedViaRest();
LookupDto dto = new LookupDto("Test Method Exposed Via Rest", true, false, lookupFieldDtos(argNames), true, "testMethodExposedViaRest", asList(argNames), true);
lookupProcessor.process(method);
Map<String, List<LookupDto>> elements = lookupProcessor.getProcessingResult();
assertTrue(elements.containsKey(TEST_CLASS_NAME));
List<LookupDto> list = elements.get(TEST_CLASS_NAME);
assertEquals(1, list.size());
assertEquals(dto, list.get(0));
}
use of org.motechproject.mds.dto.RestOptionsDto in project motech by motech.
the class RestOperationsProcessorTest method setUp.
@Before
public void setUp() throws Exception {
processor = new RestOperationsProcessor();
restOptions = new RestOptionsDto();
processor.setRestOptions(restOptions);
}
use of org.motechproject.mds.dto.RestOptionsDto in project motech by motech.
the class MdsRestBundleIT method prepareEntity.
private void prepareEntity() throws IOException {
EntityDto entityDto = new EntityDto(ENTITY_NAME);
entityDto = entityService.createEntity(entityDto);
FieldDto strField = new FieldDto(null, entityDto.getId(), TypeDto.STRING, new FieldBasicDto("strFieldDisp", "strField", true, false), false, null);
FieldDto intField = new FieldDto(null, entityDto.getId(), TypeDto.INTEGER, new FieldBasicDto("intFieldDisp", "intField"), false, null);
entityService.addFields(entityDto, asList(strField, intField));
RestOptionsDto restOptions = new RestOptionsDto(true, true, true, true, false);
restOptions.setFieldNames(prepareAllRestFieldNames(entityService.getEntityFields(entityDto.getId())));
entityService.updateRestOptions(entityDto.getId(), restOptions);
// a set based lookup for our convenience
LookupFieldDto intSetLookupField = new LookupFieldDto(null, "intField", LookupFieldType.SET);
LookupDto setLookup = new LookupDto("byIntSet", false, true, asList(intSetLookupField), false);
// list return REST lookup
LookupFieldDto intLookupField = new LookupFieldDto(null, "intField", LookupFieldType.VALUE);
LookupDto listLookup = new LookupDto("byInt", false, true, asList(intLookupField), false);
// single return REST lookup
LookupFieldDto strLookupField = new LookupFieldDto(null, "strField", LookupFieldType.VALUE);
LookupDto singleLookup = new LookupDto("byStr", true, true, asList(strLookupField), false);
entityService.addLookups(entityDto.getId(), asList(setLookup, listLookup, singleLookup));
}
Aggregations