Search in sources :

Example 16 with NamedViewDetail

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());
}
Also used : NamedViewDetail(uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Example 17 with NamedViewDetail

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));
}
Also used : GetAllNamedViews(uk.gov.gchq.gaffer.named.view.GetAllNamedViews) NamedViewDetail(uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail) Test(org.junit.jupiter.api.Test)

Example 18 with NamedViewDetail

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);
}
Also used : NamedViewDetail(uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail) Test(org.junit.jupiter.api.Test)

Example 19 with NamedViewDetail

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());
}
Also used : NamedViewDetail(uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail) Test(org.junit.jupiter.api.Test)

Example 20 with NamedViewDetail

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);
}
Also used : NamedViewDetail(uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail) Test(org.junit.jupiter.api.Test)

Aggregations

NamedViewDetail (uk.gov.gchq.gaffer.data.elementdefinition.view.NamedViewDetail)22 Test (org.junit.jupiter.api.Test)16 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)10 NamedView (uk.gov.gchq.gaffer.data.elementdefinition.view.NamedView)9 OperationView (uk.gov.gchq.gaffer.operation.graph.OperationView)7 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)7 CacheOperationFailedException (uk.gov.gchq.gaffer.named.operation.cache.exception.CacheOperationFailedException)5 ViewParameterDetail (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewParameterDetail)4 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)3 AccessPredicate (uk.gov.gchq.gaffer.access.predicate.AccessPredicate)2 UnrestrictedAccessPredicate (uk.gov.gchq.gaffer.access.predicate.UnrestrictedAccessPredicate)2 NamedViewWriteAccessPredicate (uk.gov.gchq.gaffer.data.elementdefinition.view.access.predicate.NamedViewWriteAccessPredicate)2 ExampleFilterFunction (uk.gov.gchq.gaffer.function.ExampleFilterFunction)2 GetAllNamedViews (uk.gov.gchq.gaffer.named.view.GetAllNamedViews)2 HashSet (java.util.HashSet)1 CustomUserPredicate (uk.gov.gchq.gaffer.access.predicate.user.CustomUserPredicate)1 WrappedCloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.WrappedCloseableIterable)1 RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator (uk.gov.gchq.gaffer.doc.user.generator.RoadAndRoadUseWithTimesAndCardinalitiesElementGenerator)1 Graph (uk.gov.gchq.gaffer.graph.Graph)1 AddNamedView (uk.gov.gchq.gaffer.named.view.AddNamedView)1