use of uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail in project Gaffer by gchq.
the class NamedViewCacheBackwardCompatibilityTest method shouldReturnExpectedNamedViewDetailUsingCacheDataFromVersion1_12.
@Test
public void shouldReturnExpectedNamedViewDetailUsingCacheDataFromVersion1_12() throws Exception {
final NamedViewDetail namedViewDetail = new NamedViewDetail.Builder().name(VIEW_NAME).description("standard View").creatorId(ADDING_USER.getUserId()).writers(asList("writerAuth1", "writerAuth2")).view(new View.Builder().build()).build();
final NamedViewDetail namedViewDetailFromCacheVersion1_12 = viewCache.getNamedView(namedViewDetail.getName());
assertEquals(namedViewDetail.getOrDefaultReadAccessPredicate(), namedViewDetailFromCacheVersion1_12.getOrDefaultReadAccessPredicate());
assertEquals(namedViewDetail.getOrDefaultWriteAccessPredicate(), namedViewDetailFromCacheVersion1_12.getOrDefaultWriteAccessPredicate());
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail in project Gaffer by gchq.
the class GetAllNamedViewsHandlerTest method shouldGetAllAccessibleNamedViewsFromCache.
@Test
public void shouldGetAllAccessibleNamedViewsFromCache() throws OperationException {
// Given
initialiseCache();
final NamedViewDetail namedViewAsDetail = new NamedViewDetail.Builder().name(testNamedViewName).view(view).creatorId(context.getUser().getUserId()).build();
addNamedViewHandler.doOperation(addNamedView, context, store);
final NamedViewDetail namedViewAsDetail2 = new NamedViewDetail.Builder().name(testNamedViewName + 2).view(view2).creatorId(context.getUser().getUserId()).build();
addNamedViewHandler.doOperation(addNamedView2, context, store);
addNamedViewHandler.doOperation(addNamedViewWithNoAccess, context, store);
final GetAllNamedViews getAllNamedViews = new GetAllNamedViews.Builder().build();
// when
GetAllNamedViewsHandler getAllNamedViewsHandler = new GetAllNamedViewsHandler(namedViewCache);
CloseableIterable<NamedViewDetail> namedViewList = getAllNamedViewsHandler.doOperation(getAllNamedViews, context, store);
// Then
assertEquals(2, Iterables.size(namedViewList));
assertTrue(Iterables.contains(namedViewList, namedViewAsDetail));
assertTrue(Iterables.contains(namedViewList, namedViewAsDetail2));
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail in project Gaffer by gchq.
the class NamedViewCacheTest method shouldAddNamedView.
@Test
public void shouldAddNamedView() throws CacheOperationFailedException {
cache.addNamedView(standard, false);
NamedViewDetail namedViewFromCache = cache.getNamedView(standard.getName());
assertEquals(standard, namedViewFromCache);
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail in project Gaffer by gchq.
the class NamedViewCacheTest method shouldAllowUserToOverwriteViewWithPermission.
@Test
public void shouldAllowUserToOverwriteViewWithPermission() throws CacheOperationFailedException {
// Given
NamedViewDetail namedViewDetailWithUsersAllowedToWrite = new NamedViewDetail.Builder().name(ALTERNATIVE_VIEW_NAME).description("alternative View").creatorId(advancedUser.getUserId()).writers(Arrays.asList(GAFFER_USER)).view(alternativeView).build();
cache.addNamedView(namedViewDetailWithUsersAllowedToWrite, false, advancedUser, EMPTY_ADMIN_AUTH);
// When
cache.addNamedView(new NamedViewDetail.Builder().name(ALTERNATIVE_VIEW_NAME).view("").build(), true, standardUser, EMPTY_ADMIN_AUTH);
// Then
assertEquals("", cache.getNamedView(ALTERNATIVE_VIEW_NAME).getView());
}
use of uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail in project Gaffer by gchq.
the class NamedViewCacheTest method shouldAllowUserToDeleteViewWithPermission.
@Test
public void shouldAllowUserToDeleteViewWithPermission() throws CacheOperationFailedException {
// Given
NamedViewDetail namedViewDetailWithUsersAllowedToWrite = new NamedViewDetail.Builder().name(ALTERNATIVE_VIEW_NAME).description("alternative View").creatorId(advancedUser.getUserId()).writers(Arrays.asList(GAFFER_USER)).view(alternativeView).build();
cache.addNamedView(namedViewDetailWithUsersAllowedToWrite, false, advancedUser, EMPTY_ADMIN_AUTH);
// When / Then - no exceptions
cache.deleteNamedView(ALTERNATIVE_VIEW_NAME, standardUser, EMPTY_ADMIN_AUTH);
}
Aggregations