コード例 #1
0
  @Test(expected = SecurityException.class)
  public void shouldThrowExceptionWhileReadingInstanceWithoutAnyPermission() {
    EntityDto entityDto = new EntityDto();
    entityDto.setReadOnlySecurityMode(SecurityMode.NO_ACCESS);
    entityDto.setSecurityMode(SecurityMode.NO_ACCESS);

    EntityRecord entityRecord =
        new EntityRecord(ANOTHER_ENTITY_ID, null, new ArrayList<FieldRecord>());

    when(entityService.getEntity(ANOTHER_ENTITY_ID)).thenReturn(entityDto);

    instanceService.getEntityRecords(entityRecord.getId());
  }
コード例 #2
0
  @Test
  public void shouldAcceptUserWithNoPermissionWhileReadingInstanceWithNoSecurityMode() {
    EntityDto entityDto = new EntityDto();
    entityDto.setReadOnlySecurityMode(null);
    entityDto.setSecurityMode(null);
    entityDto.setClassName(TestSample.class.getName());

    EntityRecord entityRecord = new EntityRecord(ANOTHER_ENTITY_ID, null, new ArrayList<>());

    when(entityService.getEntity(ANOTHER_ENTITY_ID)).thenReturn(entityDto);

    mockDataService();
    instanceService.getEntityRecords(entityRecord.getId());

    verify(entityService).getEntityFieldsForUI(ANOTHER_ENTITY_ID);
  }
コード例 #3
0
  @Test
  public void shouldNotUpdateGridSizeWhenUsernameIsBlank() {
    EntityDto entityDto = new EntityDto();
    entityDto.setReadOnlySecurityMode(null);
    entityDto.setSecurityMode(null);
    entityDto.setClassName(TestSample.class.getName());

    EntityRecord entityRecord = new EntityRecord(ENTITY_ID + 1, null, new ArrayList<FieldRecord>());

    when(entityService.getEntity(ENTITY_ID + 1)).thenReturn(entityDto);

    mockDataService();
    instanceService.getEntityRecords(entityRecord.getId(), new QueryParams(1, 100));

    verify(entityService).getEntityFieldsForUI(ENTITY_ID + 1);
    verify(userPreferencesService, never()).updateGridSize(anyLong(), anyString(), anyInt());
  }
コード例 #4
0
  @Test
  public void shouldUpdateGridSize() {
    setUpSecurityContext();

    EntityDto entityDto = new EntityDto();
    entityDto.setReadOnlySecurityMode(null);
    entityDto.setSecurityMode(null);
    entityDto.setClassName(TestSample.class.getName());

    EntityRecord entityRecord = new EntityRecord(ENTITY_ID + 1, null, new ArrayList<>());

    when(entityService.getEntity(ENTITY_ID + 1)).thenReturn(entityDto);

    mockDataService();
    instanceService.getEntityRecords(entityRecord.getId(), new QueryParams(1, 100));

    verify(entityService).getEntityFieldsForUI(ENTITY_ID + 1);
    verify(userPreferencesService).updateGridSize(ENTITY_ID + 1, "motech", 100);
  }