add packages, daos, etc
This commit is contained in:
parent
8585c7c93f
commit
b1a8cac64c
@ -1,3 +1,5 @@
|
||||
import db.DBConnection;
|
||||
|
||||
/*
|
||||
* This Java source file was auto generated by running 'gradle buildInit --type java-library'
|
||||
* by 'tyrelsouza' at '2/27/17 9:23 PM' with Gradle 2.10
|
||||
@ -6,8 +8,7 @@
|
||||
*/
|
||||
public class HourTracker {
|
||||
public void main(String[] args){
|
||||
|
||||
|
||||
|
||||
DBConnection db = new DBConnection();
|
||||
db.connect();
|
||||
}
|
||||
}
|
||||
|
8
src/main/java/dao/EntryDAO.java
Normal file
8
src/main/java/dao/EntryDAO.java
Normal file
@ -0,0 +1,8 @@
|
||||
package dao;
|
||||
|
||||
/**
|
||||
* Created by tyrelsouza on 2/27/17.
|
||||
*/
|
||||
public class EntryDAO {
|
||||
|
||||
}
|
35
src/main/java/dao/UserDAO.java
Normal file
35
src/main/java/dao/UserDAO.java
Normal file
@ -0,0 +1,35 @@
|
||||
package dao;
|
||||
|
||||
import model.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tyrelsouza on 2/27/17.
|
||||
CREATE TABLE entry (
|
||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`username` varchar(100) not null,
|
||||
`full_name` varchar(200) not null
|
||||
);
|
||||
*/
|
||||
public class UserDAO {
|
||||
List<User> findAll(){
|
||||
return null;
|
||||
}
|
||||
List<User> findById(int id){
|
||||
return null;
|
||||
}
|
||||
List<User> findByName(String name){
|
||||
return null;
|
||||
}
|
||||
boolean insertUser(User User){
|
||||
return false;
|
||||
}
|
||||
boolean updateUser(User User){
|
||||
return false;
|
||||
}
|
||||
boolean deleteUser(User User){
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
22
src/main/java/db/DBConnection.java
Normal file
22
src/main/java/db/DBConnection.java
Normal file
@ -0,0 +1,22 @@
|
||||
package db;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Created by tyrelsouza on 2/27/17.
|
||||
*/
|
||||
public class DBConnection {
|
||||
public static Connection conn = null;
|
||||
public static void connect(){
|
||||
try {
|
||||
conn = DriverManager.getConnection("jdbc:mysql://localhost/hourtracker?user=hourtracker&password=hours");
|
||||
} catch (SQLException e) {
|
||||
System.out.println("SQLException: " + e.getMessage());
|
||||
System.out.println("SQLState: " + e.getSQLState());
|
||||
System.out.println("VendorError: " + e.getErrorCode());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
7
src/main/java/model/Entry.java
Normal file
7
src/main/java/model/Entry.java
Normal file
@ -0,0 +1,7 @@
|
||||
package model;
|
||||
|
||||
/**
|
||||
* Created by tyrelsouza on 2/27/17.
|
||||
*/
|
||||
public class Entry {
|
||||
}
|
40
src/main/java/model/User.java
Normal file
40
src/main/java/model/User.java
Normal file
@ -0,0 +1,40 @@
|
||||
package model;
|
||||
|
||||
/**
|
||||
* Created by tyrelsouza on 2/27/17.
|
||||
*/
|
||||
public class User {
|
||||
int id;
|
||||
String username;
|
||||
String fullName;
|
||||
|
||||
public User(int id, String username, String fullName) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
|
||||
import db.DBConnection;
|
||||
import junit.framework.Assert;
|
||||
import model.User;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
@ -10,9 +13,20 @@ import static junit.framework.Assert.assertTrue;
|
||||
* @author tyrelsouza, @date 2/27/17 9:23 PM
|
||||
*/
|
||||
public class HourTrackerTest {
|
||||
// @Test
|
||||
// public void testSomeLibraryMethod() {
|
||||
// HourTracker classUnderTest = new HourTracker();
|
||||
@Test
|
||||
public void testUserCreate() {
|
||||
User user = new User(1, "tyrel", "Tyrel Souza");
|
||||
// assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod());
|
||||
// }
|
||||
|
||||
// Basic Tests for Basic Getters and setters
|
||||
Assert.assertEquals(1, user.getId());
|
||||
Assert.assertEquals("tyrel", user.getUsername());
|
||||
Assert.assertEquals("Tyrel Souza", user.getFullName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDBConnection(){
|
||||
DBConnection db = new DBConnection();
|
||||
db.connect();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user