use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method dataSetsWillBeTheSameAfterRestart.
@Test
public void dataSetsWillBeTheSameAfterRestart() throws Exception {
final DataSet dataSet = dataSetRepository.createDataSet(User.create(null, "user"), "dataset");
assertThat(dataSetRepository.dataSetExists(dataSet.getMetadata().getOwnerId(), "dataset"), is(true));
// create a new instance to simulate a restart
dataSetRepository = createDataSetRepo();
dataSetRepository.start();
assertThat(dataSetRepository.dataSetExists(dataSet.getMetadata().getOwnerId(), "dataset"), is(true));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method removeDataSetRemovesTheDataSetFromTheIndex.
@Test
public void removeDataSetRemovesTheDataSetFromTheIndex() throws Exception {
User user = User.create(null, "user");
final DataSet dataSet = dataSetRepository.createDataSet(user, "dataset");
given(permissionFetcher.getPermissions(user, dataSet.getMetadata())).willReturn(Sets.newHashSet(Permission.ADMIN));
dataSetRepository.removeDataSet(dataSet.getMetadata().getOwnerId(), "dataset", user);
assertThat(dataSetRepository.dataSetExists(dataSet.getMetadata().getOwnerId(), "dataset"), is(false));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method removeDataSetThrowsAnExceptionWhenTheUserHasNoAdminPermissions.
@Test(expected = NotEnoughPermissionsException.class)
public void removeDataSetThrowsAnExceptionWhenTheUserHasNoAdminPermissions() throws Exception {
User user = User.create(null, "user");
final DataSet dataSet = dataSetRepository.createDataSet(user, "dataset");
User userWithOutPermissions = User.create(null, "userWithOutPermissions");
dataSetRepository.removeDataSet(dataSet.getMetadata().getOwnerId(), "dataset", userWithOutPermissions);
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method publishDataSetWillReturnDataSetMetaDataWithPublishedFlagSet.
@Test
public void publishDataSetWillReturnDataSetMetaDataWithPublishedFlagSet() throws Exception {
User user = User.create(null, "user");
DataSet dataSet = dataSetRepository.createDataSet(user, "dataset");
DataSetMetaData metadata = dataSet.getMetadata();
given(permissionFetcher.getPermissions(user, dataSet.getMetadata())).willReturn(Sets.newHashSet(Permission.ADMIN, Permission.READ));
assertThat(metadata.isPublished(), is(false));
dataSetRepository.publishDataSet(user, "uuser", "dataset");
assertThat(metadata.isPublished(), is(true));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet in project timbuctoo by HuygensING.
the class PermissionBasedFieldVisibilityTest method getFieldDefinitionReturnsFieldDefinitionIfUserHasPermission.
@Test
public void getFieldDefinitionReturnsFieldDefinitionIfUserHasPermission() 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");
GraphQLFieldDefinition retrievedGraphQlFieldDefinition = permissionBasedFieldVisibility.getFieldDefinition(graphQlFieldsContainer, "user__dataSetUserHasAccessTo");
assertThat(retrievedGraphQlFieldDefinition, hasProperty("name", is("user__dataSetUserHasAccessTo")));
}
Aggregations