Search in sources :

Example 16 with AdvancedSettingsDto

use of org.motechproject.mds.dto.AdvancedSettingsDto in project motech by motech.

the class EntityProcessorTest method shouldNotOverrideHistorySettingsIfModifiedByUser.

@Test
public void shouldNotOverrideHistorySettingsIfModifiedByUser() {
    EntityDto existingEntity = new EntityDto(1L, Sample.class.getName());
    TrackingDto existingTracking = new TrackingDto();
    existingTracking.setModifiedByUser(true);
    AdvancedSettingsDto existingAdvancedSettings = new AdvancedSettingsDto();
    existingAdvancedSettings.setTracking(existingTracking);
    when(schemaHolder.getEntityByClassName(Sample.class.getName())).thenReturn(existingEntity);
    when(schemaHolder.getAdvancedSettings(Sample.class.getName())).thenReturn(existingAdvancedSettings);
    when(crudEventsProcessor.getProcessingResult()).thenReturn(existingTracking);
    processor.process(Sample.class);
    EntityDto entity = processor.getProcessingResult().get(0).getEntityProcessingResult();
    TrackingDto tracking = processor.getProcessingResult().get(0).getTrackingProcessingResult();
    assertFalse(entity.isRecordHistory());
    assertFalse(tracking.isRecordHistory());
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) InvalidSecuritySample(org.motechproject.mds.annotations.internal.samples.InvalidSecuritySample) Sample(org.motechproject.mds.annotations.internal.samples.Sample) AnotherSample(org.motechproject.mds.annotations.internal.samples.AnotherSample) RelatedSample(org.motechproject.mds.annotations.internal.samples.RelatedSample) AnotherInvalidSecuritySample(org.motechproject.mds.annotations.internal.samples.AnotherInvalidSecuritySample) ReadAccessSample(org.motechproject.mds.annotations.internal.samples.ReadAccessSample) AdvancedSettingsDto(org.motechproject.mds.dto.AdvancedSettingsDto) TrackingDto(org.motechproject.mds.dto.TrackingDto) Test(org.junit.Test)

Example 17 with AdvancedSettingsDto

use of org.motechproject.mds.dto.AdvancedSettingsDto 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));
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) LookupDto(org.motechproject.mds.dto.LookupDto) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) AdvancedSettingsDto(org.motechproject.mds.dto.AdvancedSettingsDto) Method(java.lang.reflect.Method) RestOptionsDto(org.motechproject.mds.dto.RestOptionsDto) FieldTestHelper.lookupFieldDto(org.motechproject.mds.testutil.FieldTestHelper.lookupFieldDto) FieldDto(org.motechproject.mds.dto.FieldDto) LookupFieldDto(org.motechproject.mds.dto.LookupFieldDto) Test(org.junit.Test)

Aggregations

AdvancedSettingsDto (org.motechproject.mds.dto.AdvancedSettingsDto)17 Test (org.junit.Test)7 EntityDto (org.motechproject.mds.dto.EntityDto)7 FieldDto (org.motechproject.mds.dto.FieldDto)7 ArrayList (java.util.ArrayList)5 LookupDto (org.motechproject.mds.dto.LookupDto)5 RestOptionsDto (org.motechproject.mds.dto.RestOptionsDto)5 LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)4 TrackingDto (org.motechproject.mds.dto.TrackingDto)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 AnotherSample (org.motechproject.mds.annotations.internal.samples.AnotherSample)2 ReadAccessSample (org.motechproject.mds.annotations.internal.samples.ReadAccessSample)2 MdsEntity (org.motechproject.mds.domain.MdsEntity)2 MdsVersionedEntity (org.motechproject.mds.domain.MdsVersionedEntity)2 SchemaHolder (org.motechproject.mds.dto.SchemaHolder)2 EntityInfo (org.motechproject.mds.entityinfo.EntityInfo)2 FileOutputStream (java.io.FileOutputStream)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1