-
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.
Merge remote-tracking branch 'origin/develop' into gh-3108-improve-te…
…sting-for-gafferpopvertexproperty
- Loading branch information
Showing
7 changed files
with
433 additions
and
5 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
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(); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
.../java/uk/gov/gchq/gaffer/tinkerpop/service/GafferPopNamedOperationServiceFactoryTest.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,78 @@ | ||
/* | ||
* 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.service; | ||
|
||
import org.apache.tinkerpop.gremlin.structure.service.Service; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import uk.gov.gchq.gaffer.tinkerpop.GafferPopGraph; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class GafferPopNamedOperationServiceFactoryTest { | ||
|
||
private final GafferPopGraph graph = mock(GafferPopGraph.class); | ||
|
||
@Test | ||
void shouldCreateServiceWhenStartIsTrue() { | ||
// Given | ||
final GafferPopNamedOperationServiceFactory<String, String> namedOpServiceFactory = new GafferPopNamedOperationServiceFactory<>(graph); | ||
|
||
// When | ||
final Service<String, String> namedOpService = namedOpServiceFactory.createService(true, null); | ||
|
||
// Then | ||
assertThat(namedOpService) | ||
.isNotNull() | ||
.isExactlyInstanceOf(GafferPopNamedOperationService.class); | ||
} | ||
|
||
@Test | ||
void shouldNotCreateServiceWhenStartIsFalse() { | ||
// Given | ||
final GafferPopNamedOperationServiceFactory<String, String> namedOpServiceFactory = new GafferPopNamedOperationServiceFactory<>(graph); | ||
|
||
// When / Then | ||
assertThatThrownBy(() -> namedOpServiceFactory.createService(false, null)) | ||
.isExactlyInstanceOf(UnsupportedOperationException.class) | ||
.hasMessage(Service.Exceptions.cannotUseMidTraversal); | ||
} | ||
|
||
@Test | ||
void shouldGetName() { | ||
// When | ||
final GafferPopNamedOperationServiceFactory<String, String> namedOpServiceFactory = new GafferPopNamedOperationServiceFactory<>(graph); | ||
|
||
// Then | ||
assertThat(namedOpServiceFactory.getName()) | ||
.isNotNull() | ||
.isEqualTo("namedoperation"); | ||
} | ||
|
||
@Test | ||
void shouldSupportedTypes() { | ||
// When | ||
final GafferPopNamedOperationServiceFactory<String, String> namedOpServiceFactory = new GafferPopNamedOperationServiceFactory<>(graph); | ||
|
||
// Then | ||
assertThat(namedOpServiceFactory.getSupportedTypes()) | ||
.isNotNull() | ||
.containsExactly(Service.Type.Start); | ||
} | ||
} |
Oops, something went wrong.