use of nl.knaw.huygens.timbuctoo.v5.dataset.DataSetRepository in project timbuctoo by HuygensING.
the class PermissionBasedFieldVisibilityTest method getFieldDefinitionsShowsOnlyDataSetsThatUserHasAccessTo.
@Test
public void getFieldDefinitionsShowsOnlyDataSetsThatUserHasAccessTo() throws Exception {
final DataSetRepository dataSetRepository = mock(DataSetRepository.class);
DataSet dataSet = createDataSetWithUserPermissions("user__dataSetUserHasAccessTo", Sets.newHashSet(Permission.READ));
DataSet dataSet2 = createDataSetWithUserPermissions("user__dataSetUserDoesNotHasAccessTo", Sets.newHashSet());
Collection<DataSet> dataSetCollection = Sets.newHashSet(dataSet, dataSet2);
given(dataSetRepository.getDataSets()).willReturn(dataSetCollection);
final PermissionBasedFieldVisibility permissionBasedFieldVisibility = new PermissionBasedFieldVisibility(userPermissionCheck, dataSetRepository);
final GraphQLFieldsContainer graphQlFieldsContainer = createGraphQlFieldsContainer("user__dataSetUserHasAccessTo", "user__dataSetUserDoesNotHasAccessTo");
List<GraphQLFieldDefinition> retrievedGraphQlFieldDefinitions = permissionBasedFieldVisibility.getFieldDefinitions(graphQlFieldsContainer);
assertThat(retrievedGraphQlFieldDefinitions, contains(hasProperty("name", is("user__dataSetUserHasAccessTo"))));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.DataSetRepository in project timbuctoo by HuygensING.
the class RsDocumentBuilderTest method init.
@Before
public void init() throws Exception {
dataSetRepository = mock(DataSetRepository.class);
rsDocumentBuilder = new RsDocumentBuilder(dataSetRepository, new UriHelper(URI.create("http://example.com")));
dataSet = mock(DataSet.class);
DataSetMetaData dataSetMetaData1 = mock(DataSetMetaData.class);
DataSetMetaData dataSetMetaData2 = mock(DataSetMetaData.class);
when(dataSetMetaData1.getOwnerId()).thenReturn("u1");
when(dataSetMetaData1.getDataSetId()).thenReturn("ds1");
when(dataSetMetaData2.getOwnerId()).thenReturn("u2");
when(dataSetMetaData2.getDataSetId()).thenReturn("ds2");
when(dataSet.getMetadata()).thenReturn(dataSetMetaData1).thenReturn(dataSetMetaData2);
}
Aggregations