Search in sources :

Example 6 with EdgeId

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

the class EdgeSeedTest method shouldBeNotEqualWhenSourceNotEqual.

@Test
public void shouldBeNotEqualWhenSourceNotEqual() {
    // 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("different source", destination, directed);
    // When
    final boolean isEqual = seed1.equals(seed2);
    // Then
    assertFalse(isEqual);
    assertNotEquals(seed1.hashCode(), seed2.hashCode());
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 7 with EdgeId

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

the class EdgeSeedTest method shouldSerialiseAndDeserialiseCustomVertexObjects.

@Test
public void shouldSerialiseAndDeserialiseCustomVertexObjects() throws SerialisationException {
    // Given
    final CustomVertex source = new CustomVertex();
    source.setType("sourceType");
    source.setValue("sourceValue");
    final CustomVertex destination = new CustomVertex();
    destination.setType("destinationType");
    destination.setValue("destinationValue");
    final boolean directed = true;
    final EdgeId seed = new EdgeSeed(source, destination, directed);
    // When
    final byte[] bytes = JSONSerialiser.serialise(seed);
    final EdgeId seedDeserialised = JSONSerialiser.deserialise(bytes, EdgeId.class);
    // Then
    assertTrue(seedDeserialised.getSource() instanceof CustomVertex);
    assertTrue(seedDeserialised.getDestination() instanceof CustomVertex);
    assertEquals("sourceType", ((CustomVertex) seedDeserialised.getSource()).getType());
    assertEquals("sourceValue", ((CustomVertex) seedDeserialised.getSource()).getValue());
    assertEquals("destinationType", ((CustomVertex) seedDeserialised.getDestination()).getType());
    assertEquals("destinationValue", ((CustomVertex) seedDeserialised.getDestination()).getValue());
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 8 with EdgeId

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

the class EdgeSeedTest method shouldBeRelatedToEntityIdWhenDestinationAndVertexAreNull.

@Test
public void shouldBeRelatedToEntityIdWhenDestinationAndVertexAreNull() {
    // Given
    final String source = "source";
    final String destination = null;
    final boolean directed = true;
    final EdgeId seed = new EdgeSeed(source, destination, directed);
    final EntityId relatedSeed = mock(EntityId.class);
    given(relatedSeed.getVertex()).willReturn(source);
    // When
    final boolean isRelated = seed.isRelated((ElementId) relatedSeed).isMatch();
    // Then
    assertTrue(isRelated);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 9 with EdgeId

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

the class EdgeSeedTest method shouldBeRelatedToEntityIdWhenSourceEqualsVertex.

@Test
public void shouldBeRelatedToEntityIdWhenSourceEqualsVertex() {
    // Given
    final String source = "source";
    final String destination = "destination";
    final boolean directed = true;
    final EdgeId seed = new EdgeSeed(source, destination, directed);
    final EntityId relatedSeed = mock(EntityId.class);
    given(relatedSeed.getVertex()).willReturn(source);
    // When
    final boolean isRelated = seed.isRelated((ElementId) relatedSeed).isMatch();
    // Then
    assertTrue(isRelated);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 10 with EdgeId

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

the class EdgeSeedTest method shouldSerialiseAndDeserialiseIntegersAndLongs.

@Test
public void shouldSerialiseAndDeserialiseIntegersAndLongs() throws SerialisationException {
    // Given
    final Long source = 1L;
    final Integer destination = 2;
    final boolean directed = true;
    final EdgeId seed = new EdgeSeed(source, destination, directed);
    // When
    final byte[] bytes = JSONSerialiser.serialise(seed);
    final EdgeId seedDeserialised = JSONSerialiser.deserialise(bytes, EdgeId.class);
    // Then
    assertEquals(seed, seedDeserialised);
    assertTrue(seedDeserialised.getSource() instanceof Long);
    assertTrue(seedDeserialised.getDestination() instanceof Integer);
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) 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