Search in sources :

Example 31 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class EdgeSeedTest method shouldBeNotEqualWhenDestinationNotEqual.

@Test
public void shouldBeNotEqualWhenDestinationNotEqual() {
    // Given
    final String source = "source";
    final String destination = "destination";
    final boolean directed = true;
    final EdgeId seed1 = new EdgeSeed(source, destination, directed);
    final EdgeId seed2 = new EdgeSeed(source, "different destination", directed);
    // When
    final boolean isEqual = seed1.equals(seed2);
    // Then
    assertFalse(isEqual);
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 32 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class EdgeSeedTest method shouldBeNotEqualWhenDirectedNotEqual.

@Test
public void shouldBeNotEqualWhenDirectedNotEqual() {
    // Given
    final String source = "source";
    final String destination = "destination";
    final boolean directed = true;
    final EdgeId seed1 = new EdgeSeed(source, destination, directed);
    final EdgeId seed2 = new EdgeSeed(source, destination, false);
    // When
    final boolean isEqual = seed1.equals(seed2);
    // Then
    assertFalse(isEqual);
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 33 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class UnwrapEntityIdTest method shouldReturnOriginalValueForEdgeIds.

@Test
public void shouldReturnOriginalValueForEdgeIds() {
    // Given
    final EdgeId value = mock(EdgeId.class);
    final UnwrapEntityId function = new UnwrapEntityId();
    // When
    final Object result = function.apply(value);
    // Then
    assertSame(value, result);
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Test(org.junit.jupiter.api.Test) FunctionTest(uk.gov.gchq.koryphe.function.FunctionTest)

Example 34 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class AbstractExamplesFactoryTest method shouldUseSchemaToCreateGetElementsInput.

@Test
public void shouldUseSchemaToCreateGetElementsInput() throws InstantiationException, IllegalAccessException {
    // Given
    TestExamplesFactory examplesFactory = new TestExamplesFactory(SCHEMA);
    // When
    GetElements operation = (GetElements) examplesFactory.generateExample(GetElements.class);
    // Then
    int size = 0;
    for (ElementId e : operation.getInput()) {
        size++;
        if (e instanceof EntityId) {
            assertEquals(String.class, ((EntityId) e).getVertex().getClass());
        } else {
            assertEquals(String.class, ((EdgeId) e).getDestination().getClass());
            assertEquals(String.class, ((EdgeId) e).getSource().getClass());
        }
    }
    assertEquals(2, size);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Example 35 with EdgeId

use of uk.gov.gchq.gaffer.data.element.id.EdgeId in project Gaffer by gchq.

the class AccumuloEdgeValueLoaderTest method shouldLoadAllIdentifiers.

@Test
public void shouldLoadAllIdentifiers() throws SerialisationException {
    // Given
    final String group = TestGroups.EDGE;
    final Key key = mock(Key.class);
    final Value value = mock(Value.class);
    final AccumuloElementConverter converter = mock(AccumuloElementConverter.class);
    final Schema schema = createSchema();
    final AccumuloEdgeValueLoader loader = new AccumuloEdgeValueLoader(group, key, value, converter, schema, false);
    final Edge edge = mock(Edge.class);
    final EdgeId elementId = new EdgeSeed("source", "dest", true);
    given(converter.getElementId(key, false)).willReturn(elementId);
    // When
    loader.loadIdentifiers(edge);
    // Then
    verify(edge).setIdentifiers("source", "dest", true, EdgeId.MatchedVertex.SOURCE);
    verify(converter, never()).getPropertiesFromColumnQualifier(Mockito.eq(group), Mockito.any(byte[].class));
    verify(converter, never()).getPropertiesFromColumnVisibility(Mockito.eq(group), Mockito.any(byte[].class));
    verify(converter, never()).getPropertiesFromTimestamp(Mockito.eq(group), Mockito.anyLong());
    verify(converter, never()).getPropertiesFromValue(Mockito.eq(group), Mockito.any(Value.class));
}
Also used : AccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter) Schema(uk.gov.gchq.gaffer.store.schema.Schema) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) Value(org.apache.accumulo.core.data.Value) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.jupiter.api.Test)

Aggregations

EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)40 Test (org.junit.jupiter.api.Test)27 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)18 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)15 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)14 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)8 HashMap (java.util.HashMap)5 Key (org.apache.accumulo.core.data.Key)4 FreqMap (uk.gov.gchq.gaffer.types.FreqMap)4 ArrayList (java.util.ArrayList)3 DirectedType (uk.gov.gchq.gaffer.data.element.id.DirectedType)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 HashSet (java.util.HashSet)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 Entity (uk.gov.gchq.gaffer.data.element.Entity)2 SeedMatching (uk.gov.gchq.gaffer.operation.SeedMatching)2 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 Collection (java.util.Collection)1