Search in sources :

Example 66 with EntitySeed

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

the class IfTest method shouldThrowErrorForTryingToUpdateOperationsWithTooManyOps.

@Test
public void shouldThrowErrorForTryingToUpdateOperationsWithTooManyOps() {
    // Given
    final GetElements getElements = new GetElements.Builder().input(new EntitySeed("2")).build();
    final GetAllElements getAllElements = new GetAllElements();
    final Limit limit = new Limit(5);
    final If<Object, Object> ifOp = new If.Builder<>().build();
    final Collection<Operation> opList = Lists.newArrayList(getElements, getAllElements, limit, limit);
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> ifOp.updateOperations(opList)).withMessage("Unable to update operations - exactly 3 operations are required. Received 4 operations");
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Operation(uk.gov.gchq.gaffer.operation.Operation) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 67 with EntitySeed

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

the class IfTest method shouldShallowCloneOperation.

@Test
@Override
public void shouldShallowCloneOperation() {
    // Given
    final Object input = "testInput";
    final If ifOp = new If.Builder<>().input(input).condition(true).conditional(new Conditional()).then(new GetElements.Builder().input(new EntitySeed("A")).build()).otherwise(new GetAllElements()).build();
    // When
    final If clone = ifOp.shallowClone();
    // Then
    assertNotSame(ifOp, clone);
    assertEquals(input, clone.getInput());
}
Also used : EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 68 with EntitySeed

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

the class IfTest method shouldUpdateOperations.

@Test
public void shouldUpdateOperations() {
    // Given
    final GetElements getElements = new GetElements.Builder().input(new EntitySeed("A")).build();
    final OperationChain opChain = new OperationChain.Builder().first(new GetAllElements()).then(new Limit<>(3)).build();
    final If<Object, Object> ifOp = new If.Builder<>().condition(false).build();
    final Collection<Operation> opList = Lists.newArrayList(new OperationChain<>(), getElements, opChain);
    // When
    ifOp.updateOperations(opList);
    // Then
    assertNotNull(ifOp.getThen());
    assertNotNull(ifOp.getOtherwise());
    assertEquals(getElements, ifOp.getThen());
    assertEquals(opChain, ifOp.getOtherwise());
}
Also used : OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Operation(uk.gov.gchq.gaffer.operation.Operation) OperationTest(uk.gov.gchq.gaffer.operation.OperationTest) Test(org.junit.jupiter.api.Test)

Example 69 with EntitySeed

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

the class GetWalksTest method builderShouldCreatePopulatedOperation.

@Test
@Override
public void builderShouldCreatePopulatedOperation() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new GetElements()).resultsLimit(100).build();
    // Then
    Assertions.<EntityId>assertThat(getWalks.getInput()).hasSize(2).containsOnly(new EntitySeed("1"), new EntitySeed("2"));
    assertThat(getWalks.getResultsLimit()).isEqualTo(100);
    assertThat(getWalks.getOperations()).hasSize(1);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) 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 70 with EntitySeed

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

the class GetWalksTest method shouldValidateWhenPreFiltersContainsAnOperationWhichDoesNotAllowAnInput.

@Test
public void shouldValidateWhenPreFiltersContainsAnOperationWhichDoesNotAllowAnInput() {
    // Given
    final GetWalks getWalks = new GetWalks.Builder().input(new EntitySeed("1"), new EntitySeed("2")).operations(new OperationChain.Builder().first(new ScoreOperationChain()).then(new DiscardOutput()).then(new GetElements.Builder().input().view(new View.Builder().edge(TestGroups.EDGE).build()).build()).build()).build();
    // Then
    final ValidationResult result = getWalks.validate();
    assertFalse(result.isValid());
    assertTrue(result.getErrorString().contains("The first operation in operation chain 0: " + ScoreOperationChain.class.getName() + " is not be able to accept the input seeds."), result.getErrorString());
}
Also used : 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)

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