Skip to content

Commit 2231332

Browse files
committed
debezium/dbz#1245 Add description field to connections API payload
Signed-off-by: Zihan Dai <dzh1436286758@gmail.com>
1 parent 175a59e commit 2231332

File tree

6 files changed

+60
-0
lines changed

6 files changed

+60
-0
lines changed

debezium-platform-conductor/src/main/java/io/debezium/platform/data/model/ConnectionEntity.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class ConnectionEntity {
3131
@Column(unique = true, nullable = false)
3232
private String name;
3333

34+
private String description;
35+
3436
@Enumerated(EnumType.STRING)
3537
@Column(nullable = false)
3638
private Type type;
@@ -87,6 +89,14 @@ public void setName(String name) {
8789
this.name = name;
8890
}
8991

92+
public String getDescription() {
93+
return description;
94+
}
95+
96+
public void setDescription(String description) {
97+
this.description = description;
98+
}
99+
90100
public Type getType() {
91101
return type;
92102
}

debezium-platform-conductor/src/main/java/io/debezium/platform/domain/views/Connection.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ public interface Connection extends NamedView {
2222

2323
void setName(String name);
2424

25+
String getDescription();
26+
27+
void setDescription(String description);
28+
2529
ConnectionEntity.Type getType();
2630

2731
void setType(ConnectionEntity.Type type);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- DBZ-1245 Add description field to connection table
2+
alter table if exists connection add column description varchar(255);

debezium-platform-conductor/src/test/java/io/debezium/platform/api/ConnectionResourceIT.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import static io.restassured.RestAssured.given;
99
import static org.hamcrest.CoreMatchers.is;
10+
import static org.hamcrest.CoreMatchers.nullValue;
1011
import static org.hamcrest.CoreMatchers.notNullValue;
1112

1213
import org.junit.jupiter.api.Test;
@@ -21,6 +22,7 @@ private String createTestConnectionJson(String nameSuffix) {
2122
return """
2223
{
2324
"name": "test-connection-%s",
25+
"description": "Test connection description",
2426
"type": "POSTGRESQL",
2527
"config": {
2628
"host": "localhost",
@@ -37,6 +39,7 @@ private String createUpdatedConnectionJson(Integer id, String nameSuffix) {
3739
{
3840
"id": %d,
3941
"name": "updated-connection-%s",
42+
"description": "Updated connection description",
4043
"type": "POSTGRESQL",
4144
"config": {
4245
"host": "updated-host",
@@ -74,12 +77,47 @@ public void testCreateConnection() {
7477
.header("Location", notNullValue())
7578
.body("id", notNullValue())
7679
.body("name", is("test-connection-" + nameSuffix))
80+
.body("description", is("Test connection description"))
7781
.body("type", is("POSTGRESQL"))
7882
.body("config.host", is("localhost"))
7983
.body("config.port", is(5432))
8084
.body("config.username", is("testuser"));
8185
}
8286

87+
@Test
88+
public void testCreateConnection_WithoutDescription() {
89+
String nameSuffix = String.valueOf(System.currentTimeMillis());
90+
String json = """
91+
{
92+
"name": "test-connection-no-desc-%s",
93+
"type": "POSTGRESQL",
94+
"config": {
95+
"host": "localhost",
96+
"port": 5432,
97+
"username": "testuser",
98+
"password": "testpass"
99+
}
100+
}
101+
""".formatted(nameSuffix);
102+
103+
Integer connectionId = given()
104+
.contentType(ContentType.JSON)
105+
.body(json)
106+
.when()
107+
.post("api/connections")
108+
.then()
109+
.statusCode(201)
110+
.contentType(ContentType.JSON)
111+
.body("id", notNullValue())
112+
.body("name", is("test-connection-no-desc-" + nameSuffix))
113+
.body("description", nullValue())
114+
.body("type", is("POSTGRESQL"))
115+
.extract()
116+
.path("id");
117+
118+
cleanUp(connectionId);
119+
}
120+
83121
@Test
84122
public void testGetConnectionById() {
85123
String nameSuffix = String.valueOf(System.currentTimeMillis());
@@ -103,6 +141,7 @@ public void testGetConnectionById() {
103141
.statusCode(200)
104142
.body("id", is(connectionId.intValue()))
105143
.body("name", is("test-connection-" + nameSuffix))
144+
.body("description", is("Test connection description"))
106145
.body("type", is("POSTGRESQL"))
107146
.body("config.host", is("localhost"))
108147
.body("config.port", is(5432))
@@ -149,6 +188,7 @@ public void testUpdateConnection() {
149188
.statusCode(200)
150189
.body("id", is(connectionId.intValue()))
151190
.body("name", is("updated-connection-" + updatedNameSuffix))
191+
.body("description", is("Updated connection description"))
152192
.body("config.host", is("updated-host"))
153193
.body("config.port", is(5433))
154194
.body("config.username", is("updateduser"));

debezium-platform-stage/src/__mocks__/data/Connections.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"username": "debezium",
1010
"additional-key": "additional-val"
1111
},
12+
"description": "MariaDB connection for testing",
1213
"name": "mariaconnection",
1314
"type": "MARIADB"
1415
},
@@ -17,6 +18,7 @@
1718
"config": {
1819
"test-value": "test-key"
1920
},
21+
"description": "Kinesis connection for streaming",
2022
"name": "kinesis-connection",
2123
"type": "AMAZON_KINESIS"
2224
}

debezium-platform-stage/src/apis/apis.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export type ConnectionPayload = {
8787
type: string;
8888
id?: string;
8989
config: ConnectionUnknownConfig | ConnectionAdditionalConfig;
90+
description?: string;
9091
name: string;
9192
};
9293

@@ -132,6 +133,7 @@ export type ConnectionSchema = {
132133
export type Connection = {
133134
type: string;
134135
config: ConnectionUnknownConfig;
136+
description?: string;
135137
name: string;
136138
id: number;
137139
};

0 commit comments

Comments
 (0)