Skip to content

Commit

Permalink
[+] Completed the unit tests, completely restructured the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Lei-Tin committed Nov 15, 2022
1 parent 0c1784f commit 67376de
Show file tree
Hide file tree
Showing 4 changed files with 556 additions and 338 deletions.
10 changes: 8 additions & 2 deletions src/main/java/billgates/database/MySQLDatabaseGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ public void insertEntry(int billId, QueryEntryData entry) {
Statement statement = connection.createStatement();

String query = String.format("""
INSERT INTO bill%d (value, date, currency, description, `from`, `to`, location, split_bill_id) VALUE (
%f, "%s", "%s", "%s", "%s", "%s", "%s", %d
INSERT INTO bill%d (entry_id, value, date, currency, description, `from`, `to`, location, split_bill_id) VALUE (
%d, %f, "%s", "%s", "%s", "%s", "%s", "%s", %d
)
""",
billId,
entry.getId(),
entry.getValue(),
entry.getDate().format(formatter),
entry.getCurrency(),
Expand Down Expand Up @@ -291,6 +292,7 @@ public void createUsersTable() {
return;
}


String query = """
CREATE TABLE users
(
Expand All @@ -309,5 +311,9 @@ password VARCHAR(16) NOT NULL,
}
}

public static void main(String[] args) {


}

}
5 changes: 3 additions & 2 deletions src/main/java/billgates/database/QueryEntryData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import billgates.entities.EntryBuilder;

import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;

public class QueryEntryData {
private final int id;
Expand All @@ -25,7 +26,7 @@ public QueryEntryData(int id,
String location,
int splitBillId) {
this.id = id;
this.date = date;
this.date = date.truncatedTo(ChronoUnit.SECONDS);
this.value = value;
this.currency = currency;
this.description = description;
Expand All @@ -40,7 +41,7 @@ public QueryEntryData(int id,
double value) {
// Constructor for not all values provided
this.id = id;
this.date = date;
this.date = date.truncatedTo(ChronoUnit.SECONDS);
this.value = value;
}

Expand Down
334 changes: 0 additions & 334 deletions src/test/java/TestMySQLDatabaseGateway.java

This file was deleted.

Loading

0 comments on commit 67376de

Please sign in to comment.