add packages, daos, etc

This commit is contained in:
Tyrel Souza 2017-02-27 22:56:52 -05:00
parent 8585c7c93f
commit b1a8cac64c
No known key found for this signature in database
GPG Key ID: 2EECB5087209E6A5
7 changed files with 135 additions and 8 deletions

View File

@ -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();
}
}

View File

@ -0,0 +1,8 @@
package dao;
/**
* Created by tyrelsouza on 2/27/17.
*/
public class EntryDAO {
}

View 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;
}
}

View 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();
}
}
}

View File

@ -0,0 +1,7 @@
package model;
/**
* Created by tyrelsouza on 2/27/17.
*/
public class Entry {
}

View 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;
}
}

View File

@ -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();
}
}