Search in sources :

Example 71 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class GetWalksTest method shouldValidateWhenOperationContainsMultipleHops.

@Test
public void shouldValidateWhenOperationContainsMultipleHops() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new OperationChain.Builder().first(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).then(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build()).build();
    // Then
    final ValidationResult result = getWalks.validate();
    assertFalse(result.isValid());
    assertTrue(result.getErrorString().contains("All operations must contain a single hop. Operation ") && result.getErrorString().contains(" contains multiple hops"), result.getErrorString());
}
Also used : GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 72 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class GetWalksTest method shouldValidateWhenOperationListContainsAnEmptyOperationChain.

@Test
public void shouldValidateWhenOperationListContainsAnEmptyOperationChain() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build(), new OperationChain()).build();
    // Then
    final ValidationResult result = getWalks.validate();
    assertFalse(result.isValid());
    assertTrue(result.getErrorString().contains("Operation chain 1 contains no operations"), result.getErrorString());
}
Also used : OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 73 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class GetWalksTest method shouldValidateOperationWhenSecondOperationContainsNonNullInput.

@Test
public void shouldValidateOperationWhenSecondOperationContainsNonNullInput() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).addOperations(new GetElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).build()).build(), new GetElements.Builder().input(new EntitySeed("seed")).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build();
    // Then
    assertFalse(getWalks.validate().isValid());
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 74 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class GetWalksTest method shouldValidateWhenOperationListDoesNotContainAGetElementsOperation.

@Test
public void shouldValidateWhenOperationListDoesNotContainAGetElementsOperation() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build(), new OperationChain.Builder().first(new AddElements()).build(), new GetElements.Builder().input((Iterable<? extends ElementId>) null).view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build();
    // Then
    final ValidationResult result = getWalks.validate();
    assertFalse(result.isValid());
    assertTrue(result.getErrorString().contains("All operations must contain a single hop. Operation 1 does not contain a hop."), result.getErrorString());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 75 with EntitySeed

use of uk.gov.gchq.gaffer.operation.data.EntitySeed in project Gaffer by gchq.

the class ToElementIdTest method shouldReturnOriginalValueIfInputIsAnEntitySeed.

@Test
public void shouldReturnOriginalValueIfInputIsAnEntitySeed() {
    // Given
    final EntitySeed input = new EntitySeed("item");
    final ToElementId function = new ToElementId();
    // When
    final ElementId output = function.apply(input);
    // Then
    assertSame(input, output);
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Aggregations

EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)284 Test (org.junit.jupiter.api.Test)122 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)122 Element (uk.gov.gchq.gaffer.data.element.Element)102 User (uk.gov.gchq.gaffer.user.User)92 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)90 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)87 HashSet (java.util.HashSet)71 Graph (uk.gov.gchq.gaffer.graph.Graph)69 Entity (uk.gov.gchq.gaffer.data.element.Entity)65 Edge (uk.gov.gchq.gaffer.data.element.Edge)61 Test (org.junit.Test)58 ArrayList (java.util.ArrayList)55 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)46 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)41 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)40 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)38 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)36 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)36 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)35