Skip to content

Commit df8bf6f

Browse files
Implement new BDD connection opening syntax (#412)
## What is the goal of this PR? We implement the new BDD connection/user connection syntax set up in typedb/typedb-behaviour#244. ## What are the changes implemented in this PR? Update the BDD step definitions to reflect new syntax from the behaviour repository.
1 parent cd20a76 commit df8bf6f

File tree

7 files changed

+61
-37
lines changed

7 files changed

+61
-37
lines changed

dependencies/vaticle/artifacts.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def vaticle_typedb_artifact():
2929
artifact_name = "typedb-server-{platform}-{version}.{ext}",
3030
tag_source = deployment["artifact.release"],
3131
commit_source = deployment["artifact.snapshot"],
32-
commit = "c78d79b00894a65dd94f219339419b278a9663dd",
32+
commit = "c36d4deeb6a7f9b53dced92002e57c1df9963f7a",
3333
)
3434

3535
def vaticle_typedb_cluster_artifact():
@@ -39,5 +39,5 @@ def vaticle_typedb_cluster_artifact():
3939
artifact_name = "typedb-cluster-all-{platform}-{version}.{ext}",
4040
tag_source = deployment_private["artifact.release"],
4141
commit_source = deployment_private["artifact.snapshot"],
42-
commit = "b00b9f016899b924fc8a083ff6183341a601f65e",
42+
commit = "230757ad05e2b1a8cf78a3cb67d90d759de64a19",
4343
)

dependencies/vaticle/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def vaticle_typedb_behaviour():
5353
git_repository(
5454
name = "vaticle_typedb_behaviour",
5555
remote = "https://github.com/vaticle/typedb-behaviour",
56-
commit = "c75c64d42725163e62078218207efbcb2b5ed845" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
56+
commit = "b4cbdd3aaf28428608fc88eae0852425df57fe25" # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
5757
)
5858

5959
def vaticle_factory_tracing():

test/behaviour/concept/type/thingtype/ThingTypeSteps.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
public class ThingTypeSteps {
4747

48-
private static final String UNRECOGNISED_VALUE = "Unrecognized value";
48+
private static final String ILLEGAL_ARGUMENT = "Illegal argument.";
4949

5050
public static ThingType get_thing_type(RootLabel rootLabel, String typeLabel) {
5151
switch (rootLabel) {
@@ -55,8 +55,10 @@ public static ThingType get_thing_type(RootLabel rootLabel, String typeLabel) {
5555
return tx().concepts().getAttributeType(typeLabel);
5656
case RELATION:
5757
return tx().concepts().getRelationType(typeLabel);
58+
case THING:
59+
return tx().concepts().getRootThingType();
5860
default:
59-
throw new IllegalArgumentException(UNRECOGNISED_VALUE);
61+
throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
6062
}
6163
}
6264

@@ -94,7 +96,7 @@ public void put_thing_type(RootLabel rootLabel, String typeLabel) {
9496
tx().concepts().putRelationType(typeLabel);
9597
break;
9698
default:
97-
throw new IllegalArgumentException(UNRECOGNISED_VALUE);
99+
throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
98100
}
99101
}
100102

@@ -160,6 +162,8 @@ public void thing_type_set_supertype(RootLabel rootLabel, String typeLabel, Stri
160162
RelationType relationSuperType = tx().concepts().getRelationType(superLabel);
161163
tx().concepts().getRelationType(typeLabel).asRemote(tx()).setSupertype(relationSuperType);
162164
break;
165+
case THING:
166+
throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
163167
}
164168
}
165169

@@ -178,6 +182,8 @@ public void thing_type_set_supertype_throws_exception(RootLabel rootLabel, Strin
178182
RelationType relationSuperType = tx().concepts().getRelationType(superLabel);
179183
assertThrows(() -> tx().concepts().getRelationType(typeLabel).asRemote(tx()).setSupertype(relationSuperType));
180184
break;
185+
case THING:
186+
throw new IllegalArgumentException(ILLEGAL_ARGUMENT);
181187
}
182188
}
183189

test/behaviour/config/Parameters.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public LocalDateTime datetime(String dateTime) {
5656
return LocalDateTime.parse(dateTime, formatter);
5757
}
5858

59-
@ParameterType("entity|attribute|relation")
59+
@ParameterType("entity|attribute|relation|thing")
6060
public RootLabel root_label(String type) {
6161
return RootLabel.of(type);
6262
}
@@ -134,7 +134,8 @@ public List<TypeDBTransaction.Type> transaction_types(List<String> values) {
134134
public enum RootLabel {
135135
ENTITY("entity"),
136136
ATTRIBUTE("attribute"),
137-
RELATION("relation");
137+
RELATION("relation"),
138+
THING("thing");
138139

139140
private final String label;
140141

test/behaviour/connection/ConnectionStepsBase.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.vaticle.typedb.client.api.TypeDBSession;
2727
import com.vaticle.typedb.client.api.TypeDBTransaction;
2828
import com.vaticle.typedb.common.test.TypeDBSingleton;
29+
import io.cucumber.java.en.When;
2930

3031
import java.util.ArrayList;
3132
import java.util.HashMap;
@@ -113,7 +114,12 @@ void after() {
113114

114115
abstract TypeDBOptions createOptions();
115116

116-
abstract void open_connection();
117+
abstract void connection_opens_with_default_authentication();
118+
119+
void connection_closes() {
120+
client.close();
121+
client = null;
122+
}
117123

118124
void connection_has_been_opened() {
119125
assertNotNull(client);

test/behaviour/connection/ConnectionStepsCluster.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,38 @@ TypeDBOptions createOptions() {
7171
}
7272

7373
@Override
74-
@When("open connection")
75-
public void open_connection() {
74+
@When("connection opens with default authentication")
75+
public void connection_opens_with_default_authentication() {
7676
client = createTypeDBClient(TypeDBSingleton.getTypeDBRunner().address());
7777
}
7878

79+
@When("connection opens with authentication: {word}, {word}")
80+
public void connection_opens_with_authentication(String username, String password) {
81+
if (client != null) {
82+
client.close();
83+
client = null;
84+
}
85+
86+
client = createTypeDBClient(TypeDBSingleton.getTypeDBRunner().address(), username, password, false);
87+
}
88+
89+
@When("connection opens with authentication: {word}, {word}; throws exception")
90+
public void connection_opens_with_authentication_throws_exception(String username, String password) {
91+
assertThrows(() -> createTypeDBClient(TypeDBSingleton.getTypeDBRunner().address(), username, password, false));
92+
}
93+
94+
@Override
7995
@Given("connection has been opened")
8096
public void connection_has_been_opened() {
8197
super.connection_has_been_opened();
8298
}
8399

100+
@Override
101+
@When("connection closes")
102+
public void connection_closes() {
103+
super.connection_closes();
104+
}
105+
84106
@Given("typedb has configuration")
85107
public void typedb_has_configuration(Map<String, String> map) {
86108
TypeDBSingleton.deleteTypeDBRunner();
@@ -109,27 +131,8 @@ public void typedb_stops() {
109131
TypeDBSingleton.getTypeDBRunner().stop();
110132
}
111133

112-
@When("user connect: {word}, {word}")
113-
public void user_connect(String username, String password) {
114-
if (client != null) {
115-
client.close();
116-
client = null;
117-
}
118-
119-
client = createTypeDBClient(TypeDBSingleton.getTypeDBRunner().address(), username, password, false);
120-
}
121-
122-
@When("user disconnect")
123-
public void disconnect_current_user() {
124-
client.close();
125-
client = null;
126-
}
127-
128-
@When("user connect: {word}, {word}; throws exception")
129-
public void user_connect_throws_exception(String username, String password) {
130-
assertThrows(() -> createTypeDBClient(TypeDBSingleton.getTypeDBRunner().address(), username, password, false));
131-
}
132134

135+
@Override
133136
@Given("connection does not have any database")
134137
public void connection_does_not_have_any_database() {
135138
super.connection_does_not_have_any_database();

test/behaviour/connection/ConnectionStepsCore.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ TypeDBOptions createOptions() {
6060
return TypeDBOptions.core();
6161
}
6262

63-
@Override
64-
@When("open connection")
65-
public void open_connection() {
66-
client = createTypeDBClient(TypeDBSingleton.getTypeDBRunner().address());
67-
}
68-
6963
@When("typedb starts")
7064
public void typedb_starts() {
7165
TypeDBRunner runner = TypeDBSingleton.getTypeDBRunner();
@@ -87,11 +81,25 @@ public void typedb_stops() {
8781
TypeDBSingleton.getTypeDBRunner().stop();
8882
}
8983

84+
@Override
85+
@When("connection opens with default authentication")
86+
public void connection_opens_with_default_authentication() {
87+
client = createTypeDBClient(TypeDBSingleton.getTypeDBRunner().address());
88+
}
89+
90+
@Override
91+
@When("connection closes")
92+
public void connection_closes() {
93+
super.connection_closes();
94+
}
95+
96+
@Override
9097
@Given("connection has been opened")
9198
public void connection_has_been_opened() {
9299
super.connection_has_been_opened();
93100
}
94101

102+
@Override
95103
@Given("connection does not have any database")
96104
public void connection_does_not_have_any_database() {
97105
super.connection_does_not_have_any_database();

0 commit comments

Comments
 (0)