-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: GCHQDeveloper314 <94527357+GCHQDeveloper314@users.noreply.github.com> Co-authored-by: t92549 <80890692+t92549@users.noreply.github.com>
- Loading branch information
1 parent
d48db5e
commit 1ef3621
Showing
2 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
library/tinkerpop/src/test/java/uk/gov/gchq/gaffer/tinkerpop/GafferPopGraphFeaturesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright 2023 Crown Copyright | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package uk.gov.gchq.gaffer.tinkerpop; | ||
|
||
import org.apache.tinkerpop.gremlin.structure.Graph.Features; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import uk.gov.gchq.gaffer.tinkerpop.GafferPopGraphFeatures.GafferPopGraphEdgeFeatures; | ||
import uk.gov.gchq.gaffer.tinkerpop.GafferPopGraphFeatures.GafferPopGraphGraphFeatures; | ||
import uk.gov.gchq.gaffer.tinkerpop.GafferPopGraphFeatures.GafferPopGraphVertexFeatures; | ||
import uk.gov.gchq.gaffer.tinkerpop.GafferPopGraphFeatures.GafferPopGraphVertexPropertyFeatures; | ||
import uk.gov.gchq.gaffer.types.TypeSubTypeValue; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class GafferPopGraphFeaturesTest { | ||
public static final String STRING_ID = "testId"; | ||
public static final Integer INT_ID = 1; | ||
public static final UUID UUID_ID = UUID.randomUUID(); | ||
public static final TypeSubTypeValue TSTV_ID = new TypeSubTypeValue("myType", "mySubType", "30"); | ||
final GafferPopGraph graph = mock(GafferPopGraph.class); | ||
final Features features = new GafferPopGraphFeatures(); | ||
|
||
@Test | ||
void shouldHaveCertainGafferPopGraphGraphFeatures() { | ||
given(graph.features()).willReturn(features); | ||
final Features graphFeatures = graph.features(); | ||
|
||
assertThat(graphFeatures.graph()).isInstanceOf(GafferPopGraphGraphFeatures.class); | ||
assertThat(graphFeatures.graph().supportsTransactions()).isFalse(); | ||
assertThat(graphFeatures.graph().supportsThreadedTransactions()).isFalse(); | ||
assertThat(graphFeatures.graph().supportsComputer()).isFalse(); | ||
} | ||
|
||
@Test | ||
void shouldHaveCertainGafferPopGraphVertexFeatures() { | ||
given(graph.features()).willReturn(features); | ||
|
||
final Features vertexFeatures = graph.features(); | ||
|
||
assertThat(vertexFeatures.vertex()).isInstanceOf(GafferPopGraphVertexFeatures.class); | ||
assertThat(vertexFeatures.vertex().supportsRemoveVertices()).isFalse(); | ||
assertThat(vertexFeatures.vertex().supportsRemoveProperty()).isFalse(); | ||
assertThat(vertexFeatures.vertex().willAllowId(STRING_ID)).isTrue(); | ||
assertThat(vertexFeatures.vertex().willAllowId(INT_ID)).isTrue(); | ||
assertThat(vertexFeatures.vertex().willAllowId(UUID_ID)).isTrue(); | ||
assertThat(vertexFeatures.vertex().willAllowId(TSTV_ID)).isTrue(); | ||
assertThat(vertexFeatures.vertex().willAllowId(null)).isFalse(); | ||
} | ||
|
||
@Test | ||
void shouldHaveCertainGafferPopGraphEdgeFeatures() { | ||
given(graph.features()).willReturn(features); | ||
|
||
final Features edgeFeatures = graph.features(); | ||
|
||
assertThat(edgeFeatures.edge()).isInstanceOf(GafferPopGraphEdgeFeatures.class); | ||
assertThat(edgeFeatures.edge().supportsRemoveEdges()).isFalse(); | ||
assertThat(edgeFeatures.edge().supportsRemoveProperty()).isFalse(); | ||
assertThat(edgeFeatures.edge().willAllowId(STRING_ID)).isTrue(); | ||
assertThat(edgeFeatures.vertex().willAllowId(INT_ID)).isTrue(); | ||
assertThat(edgeFeatures.vertex().willAllowId(UUID_ID)).isTrue(); | ||
assertThat(edgeFeatures.vertex().willAllowId(TSTV_ID)).isTrue(); | ||
assertThat(edgeFeatures.vertex().willAllowId(null)).isFalse(); | ||
} | ||
|
||
@Test | ||
void shouldReturnStringOfFeatures() { | ||
given(graph.features()).willReturn(features); | ||
|
||
assertThat(graph.features().toString()).contains("FEATURES", "GraphFeatures", "VariableFeatures", | ||
"VertexFeatures", "VertexPropertyFeatures", "EdgeFeatures", "EdgePropertyFeatures"); | ||
} | ||
|
||
@Test | ||
void shouldHaveCertainGafferPopGraphVertexPropertyFeatures() { | ||
given(graph.features()).willReturn(features); | ||
|
||
final Features.VertexPropertyFeatures vertexPropertyFeatures = graph.features().vertex().properties(); | ||
|
||
assertThat(vertexPropertyFeatures).isInstanceOf(GafferPopGraphVertexPropertyFeatures.class); | ||
assertThat(vertexPropertyFeatures.supportsRemoveProperty()).isFalse(); | ||
assertThat(vertexPropertyFeatures.willAllowId(STRING_ID)).isTrue(); | ||
assertThat(vertexPropertyFeatures.willAllowId(INT_ID)).isTrue(); | ||
assertThat(vertexPropertyFeatures.willAllowId(UUID_ID)).isTrue(); | ||
assertThat(vertexPropertyFeatures.willAllowId(TSTV_ID)).isTrue(); | ||
assertThat(vertexPropertyFeatures.willAllowId(null)).isFalse(); | ||
} | ||
} |