Skip to content

Commit

Permalink
refacator: update create table process creation
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Santana <[email protected]>
  • Loading branch information
otaviojava committed Nov 28, 2023
1 parent 03e7b07 commit 20e4f3d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private TableBuilder(String schema, String table, Server server) {
*/
public boolean id(String id) {
Objects.requireNonNull(id, "id is required");
return this.server.createTable(new CreateTable(schema, table, id));
return this.server.executeTableCreation(new CreateTable(schema, table, id));
}
}
}
4 changes: 2 additions & 2 deletions core/src/main/java/expert/os/harperdb/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public boolean schema(String schema) {
* @return A CreateTableBuilder instance to further configure the "create table" operation.
* @throws NullPointerException if the provided schema is null.
*/
public CreateTableBuilder table(String schema){
public CreateTableBuilder createTable(String schema){
Objects.requireNonNull(schema, "schema is required");
return new CreateTableBuilder(schema, this);
}

boolean createTable(CreateTable operation) {
boolean executeTableCreation(CreateTable operation) {
HttpRequest request = createRequest()
.POST(ofByteArray(INSTANCE.writeValueAsBytes(operation)))
.build();
Expand Down
9 changes: 3 additions & 6 deletions core/src/test/java/expert/os/harperdb/ServerTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package expert.os.harperdb;

import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class ServerTest {

private final Container container = Container.INSTANCE;
Expand Down Expand Up @@ -38,9 +35,9 @@ void shouldNotCreateSchemaDuplicated() {
void shouldReturnNPEWhenSchemaIsNull() {
Server server = getServer();

Assertions.assertThrows(NullPointerException.class, () -> server.table(null));
Assertions.assertThrows(NullPointerException.class, () -> server.table("schema").table(null));
Assertions.assertThrows(NullPointerException.class, () -> server.table("schema").table("table").id(null));
Assertions.assertThrows(NullPointerException.class, () -> server.createTable(null));
Assertions.assertThrows(NullPointerException.class, () -> server.createTable("schema").table(null));
Assertions.assertThrows(NullPointerException.class, () -> server.createTable("schema").table("table").id(null));
}

private Server getServer() {
Expand Down

0 comments on commit 20e4f3d

Please sign in to comment.