Fixed 0 start time bug
This commit is contained in:
parent
2ebda7ab71
commit
9f5883bdee
3 changed files with 124 additions and 14 deletions
|
@ -1,5 +1,29 @@
|
||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
|
<DBN-PSQL>
|
||||||
|
<case-options enabled="false">
|
||||||
|
<option name="KEYWORD_CASE" value="lower" />
|
||||||
|
<option name="FUNCTION_CASE" value="lower" />
|
||||||
|
<option name="PARAMETER_CASE" value="lower" />
|
||||||
|
<option name="DATATYPE_CASE" value="lower" />
|
||||||
|
<option name="OBJECT_CASE" value="preserve" />
|
||||||
|
</case-options>
|
||||||
|
<formatting-settings enabled="false" />
|
||||||
|
</DBN-PSQL>
|
||||||
|
<DBN-SQL>
|
||||||
|
<case-options enabled="false">
|
||||||
|
<option name="KEYWORD_CASE" value="lower" />
|
||||||
|
<option name="FUNCTION_CASE" value="lower" />
|
||||||
|
<option name="PARAMETER_CASE" value="lower" />
|
||||||
|
<option name="DATATYPE_CASE" value="lower" />
|
||||||
|
<option name="OBJECT_CASE" value="preserve" />
|
||||||
|
</case-options>
|
||||||
|
<formatting-settings enabled="false">
|
||||||
|
<option name="STATEMENT_SPACING" value="one_line" />
|
||||||
|
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
|
||||||
|
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
|
||||||
|
</formatting-settings>
|
||||||
|
</DBN-SQL>
|
||||||
<Objective-C-extensions>
|
<Objective-C-extensions>
|
||||||
<file>
|
<file>
|
||||||
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
<option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="Import" />
|
||||||
|
@ -25,5 +49,29 @@
|
||||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||||
</extensions>
|
</extensions>
|
||||||
</Objective-C-extensions>
|
</Objective-C-extensions>
|
||||||
|
<DBN-PSQL>
|
||||||
|
<case-options enabled="false">
|
||||||
|
<option name="KEYWORD_CASE" value="lower" />
|
||||||
|
<option name="FUNCTION_CASE" value="lower" />
|
||||||
|
<option name="PARAMETER_CASE" value="lower" />
|
||||||
|
<option name="DATATYPE_CASE" value="lower" />
|
||||||
|
<option name="OBJECT_CASE" value="preserve" />
|
||||||
|
</case-options>
|
||||||
|
<formatting-settings enabled="false" />
|
||||||
|
</DBN-PSQL>
|
||||||
|
<DBN-SQL>
|
||||||
|
<case-options enabled="false">
|
||||||
|
<option name="KEYWORD_CASE" value="lower" />
|
||||||
|
<option name="FUNCTION_CASE" value="lower" />
|
||||||
|
<option name="PARAMETER_CASE" value="lower" />
|
||||||
|
<option name="DATATYPE_CASE" value="lower" />
|
||||||
|
<option name="OBJECT_CASE" value="preserve" />
|
||||||
|
</case-options>
|
||||||
|
<formatting-settings enabled="false">
|
||||||
|
<option name="STATEMENT_SPACING" value="one_line" />
|
||||||
|
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
|
||||||
|
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
|
||||||
|
</formatting-settings>
|
||||||
|
</DBN-SQL>
|
||||||
</code_scheme>
|
</code_scheme>
|
||||||
</component>
|
</component>
|
|
@ -256,8 +256,8 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
values.put(COLUMN_COMPANY, company);
|
values.put(COLUMN_COMPANY, company);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean licensed = serviceProvider.isLicensed();
|
String licensed = String.valueOf(serviceProvider.isLicensed());
|
||||||
values.put(COLUMN_LICENSED, Boolean.toString(licensed));
|
values.put(COLUMN_LICENSED, licensed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
if (address != null && !address.equals(""))values.put(COLUMN_ADDRESS, address);
|
if (address != null && !address.equals(""))values.put(COLUMN_ADDRESS, address);
|
||||||
if (phonenumber != null && !phonenumber.equals(""))values.put(COLUMN_PHONE, phonenumber);
|
if (phonenumber != null && !phonenumber.equals(""))values.put(COLUMN_PHONE, phonenumber);
|
||||||
if (companyname != null && !companyname.equals(""))values.put(COLUMN_COMPANY, companyname);
|
if (companyname != null && !companyname.equals(""))values.put(COLUMN_COMPANY, companyname);
|
||||||
if (licensed != null)values.put(COLUMN_LICENSED, Boolean.toString(licensed));
|
if (licensed != null)values.put(COLUMN_LICENSED, String.valueOf(licensed));
|
||||||
|
|
||||||
|
|
||||||
return writeDB.update(TABLE_LOGIN, values, COLUMN_USERNAME+" = ?",
|
return writeDB.update(TABLE_LOGIN, values, COLUMN_USERNAME+" = ?",
|
||||||
|
@ -543,7 +543,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
new String[]{serviceProviderUsername, serviceName},
|
new String[]{serviceProviderUsername, serviceName},
|
||||||
null, null, null,
|
null, null, null,
|
||||||
"1");
|
"1");
|
||||||
//If cursor has 1+ elements in it, username already exists in table
|
//If cursor has 1+ elements in it, username/service combination already exists in table
|
||||||
if (cursor != null && cursor.getCount() > 0){
|
if (cursor != null && cursor.getCount() > 0){
|
||||||
cursor.close();
|
cursor.close();
|
||||||
return false;
|
return false;
|
||||||
|
@ -629,6 +629,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
addAvailabilityToContentValues(contentValues, COLUMN_FRISTART, COLUMN_FRIEND, availabilities[4]);
|
addAvailabilityToContentValues(contentValues, COLUMN_FRISTART, COLUMN_FRIEND, availabilities[4]);
|
||||||
addAvailabilityToContentValues(contentValues, COLUMN_SATSTART, COLUMN_SATEND, availabilities[5]);
|
addAvailabilityToContentValues(contentValues, COLUMN_SATSTART, COLUMN_SATEND, availabilities[5]);
|
||||||
addAvailabilityToContentValues(contentValues, COLUMN_SUNSTART, COLUMN_SUNEND, availabilities[6]);
|
addAvailabilityToContentValues(contentValues, COLUMN_SUNSTART, COLUMN_SUNEND, availabilities[6]);
|
||||||
|
|
||||||
if (!cursor.moveToFirst()){
|
if (!cursor.moveToFirst()){
|
||||||
contentValues.put(COLUMN_AVAILABILITYNAME, serviceProvider.getUsername());
|
contentValues.put(COLUMN_AVAILABILITYNAME, serviceProvider.getUsername());
|
||||||
writeDB.insert(TABLE_AVAILABILITY, null, contentValues);
|
writeDB.insert(TABLE_AVAILABILITY, null, contentValues);
|
||||||
|
@ -648,7 +649,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
||||||
} else {
|
} else {
|
||||||
int startTime = startAndEndTimes[0]*60+startAndEndTimes[1];
|
int startTime = startAndEndTimes[0]*60+startAndEndTimes[1];
|
||||||
int endTime = startAndEndTimes[2]*60+startAndEndTimes[3];
|
int endTime = startAndEndTimes[2]*60+startAndEndTimes[3];
|
||||||
if (endTime - startTime <=0 || startTime > 1439 || startTime <= 0
|
if (endTime - startTime <=0 || startTime > 1439 || startTime < 0
|
||||||
|| endTime > 1439 || endTime <= 0) {
|
|| endTime > 1439 || endTime <= 0) {
|
||||||
contentValues.put(startColumn, 0);
|
contentValues.put(startColumn, 0);
|
||||||
contentValues.put(endColumn, 0);
|
contentValues.put(endColumn, 0);
|
||||||
|
|
|
@ -173,6 +173,8 @@ public class DBIntegrationTest {
|
||||||
assertTrue(added);
|
assertTrue(added);
|
||||||
added = dbHelper.addService(new Service("Exterminating flatworms", 25.00));
|
added = dbHelper.addService(new Service("Exterminating flatworms", 25.00));
|
||||||
assertTrue(!added);
|
assertTrue(!added);
|
||||||
|
added = dbHelper.addService(new Service("extermiNating fLatworms", 25.00));
|
||||||
|
assertTrue(!added);
|
||||||
|
|
||||||
dbHelper.deleteService("Exterminating flatworms");
|
dbHelper.deleteService("Exterminating flatworms");
|
||||||
}
|
}
|
||||||
|
@ -227,16 +229,19 @@ public class DBIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllServicesProvidedByUserAndDeleteService(){
|
public void testGetAllServicesProvidedByUserAndDeleteService(){
|
||||||
dbHelper.addUser(new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true));
|
"testaddress", "8888888888", "companydotcom", true);
|
||||||
|
dbHelper.addUser(serviceProvider);
|
||||||
|
|
||||||
dbHelper.addService(new Service("Hitman", 12358));
|
Service service1 = new Service("Hitman", 12358);
|
||||||
dbHelper.addService(new Service("Exterminating flatworms", 392.457));
|
Service service2 = new Service("Exterminating flatworms", 392.457);
|
||||||
|
dbHelper.addService(service1);
|
||||||
|
dbHelper.addService(service2);
|
||||||
|
|
||||||
dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "hitman");
|
dbHelper.addServiceProvidedByUser(serviceProvider, service1);
|
||||||
dbHelper.addServiceProvidedByUser("jbO4aBF4dC", "exterminating flatworms");
|
dbHelper.addServiceProvidedByUser(serviceProvider, service2);
|
||||||
|
|
||||||
List<String[]> servicesProvidedByUser = dbHelper.getAllServicesProvidedByUser("jbO4aBF4dC");
|
List<String[]> servicesProvidedByUser = dbHelper.getAllServicesProvidedByUser(serviceProvider);
|
||||||
assertEquals(2, servicesProvidedByUser.size());
|
assertEquals(2, servicesProvidedByUser.size());
|
||||||
assertEquals("hitman", servicesProvidedByUser.get(0)[0]);
|
assertEquals("hitman", servicesProvidedByUser.get(0)[0]);
|
||||||
assertEquals(12358, Double.parseDouble(servicesProvidedByUser.get(0)[1]), 0.00001);
|
assertEquals(12358, Double.parseDouble(servicesProvidedByUser.get(0)[1]), 0.00001);
|
||||||
|
@ -281,13 +286,17 @@ public class DBIntegrationTest {
|
||||||
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true);
|
||||||
serviceProvider.setAvailabilities(0, 4, 18, 19, 30);
|
serviceProvider.setAvailabilities(0, 4, 18, 19, 30);
|
||||||
serviceProvider.setAvailabilities(3, 8, 12, 15, 14);
|
serviceProvider.setAvailabilities(1, 5, 20, 21, 11);
|
||||||
|
serviceProvider.setAvailabilities(3, 7, 12, 15, 14);
|
||||||
|
serviceProvider.setAvailabilities(4, 0, 0, 23, 29);
|
||||||
|
|
||||||
//TODO:Perhaps implement a deep clone function for UserType?
|
//TODO:Perhaps implement a deep clone function for UserType?
|
||||||
ServiceProvider serviceProvider2 = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
ServiceProvider serviceProvider2 = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
"testaddress", "8888888888", "companydotcom", true);
|
"testaddress", "8888888888", "companydotcom", true);
|
||||||
serviceProvider2.setAvailabilities(0, 4, 18, 19, 30);
|
serviceProvider2.setAvailabilities(0, 4, 18, 19, 30);
|
||||||
serviceProvider2.setAvailabilities(3, 8, 12, 15, 14);
|
serviceProvider2.setAvailabilities(1, 5, 20, 21, 11);
|
||||||
|
serviceProvider2.setAvailabilities(3, 7, 12, 15, 14);
|
||||||
|
serviceProvider2.setAvailabilities(4, 0, 0, 23, 29);
|
||||||
|
|
||||||
dbHelper.addUser(serviceProvider2);
|
dbHelper.addUser(serviceProvider2);
|
||||||
|
|
||||||
|
@ -307,5 +316,57 @@ public class DBIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddServiceProvider(){
|
||||||
|
ServiceProvider serviceProvider = new ServiceProvider("7MuF1c59XP", null, null, null,
|
||||||
|
"testaddress", "8888888888", "companydotcom", true);
|
||||||
|
dbHelper.addUser(serviceProvider);
|
||||||
|
|
||||||
|
UserType userType = dbHelper.findUserByUsername("7MuF1c59XP");
|
||||||
|
assertTrue(userType instanceof ServiceProvider);
|
||||||
|
ServiceProvider dbServiceProvider = (ServiceProvider) userType;
|
||||||
|
assertEquals(serviceProvider.getAddress(), dbServiceProvider.getAddress());
|
||||||
|
assertEquals(serviceProvider.getPhonenumber(), dbServiceProvider.getPhonenumber());
|
||||||
|
assertEquals(serviceProvider.getCompanyname(), dbServiceProvider.getCompanyname());
|
||||||
|
assertEquals(serviceProvider.isLicensed(), dbServiceProvider.isLicensed());
|
||||||
|
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
|
// public void testDeleteServiceProvidedByUser(){
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
// public void testInvalidAvailability(){
|
||||||
|
// ServiceProvider serviceProvider = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
|
// "testaddress", "8888888888", "companydotcom", true);
|
||||||
|
// serviceProvider.setAvailabilities(0, 4, 18, 19, 30);
|
||||||
|
// serviceProvider.setAvailabilities(3, 8, 12, 15, 14);
|
||||||
|
//
|
||||||
|
// //TODO:Perhaps implement a deep clone function for UserType?
|
||||||
|
// ServiceProvider serviceProvider2 = new ServiceProvider("jbO4aBF4dC", null, null, null,
|
||||||
|
// "testaddress", "8888888888", "companydotcom", true);
|
||||||
|
// serviceProvider2.setAvailabilities(0, 4, 18, 19, 30);
|
||||||
|
// serviceProvider2.setAvailabilities(3, 8, 12, 15, 14);
|
||||||
|
//
|
||||||
|
// dbHelper.addUser(serviceProvider2);
|
||||||
|
//
|
||||||
|
// boolean updated = dbHelper.updateAvailability(serviceProvider2);
|
||||||
|
// assertTrue(updated);
|
||||||
|
//
|
||||||
|
// serviceProvider2.setAvailabilities(3, 8, 12, 15, 10);
|
||||||
|
// int[][] dbAvailabilities = dbHelper.getAvailabilities(serviceProvider2);
|
||||||
|
// int[][] availabilities = serviceProvider.getAvailabilities();
|
||||||
|
//
|
||||||
|
// assertEquals(14, serviceProvider2.getAvailabilities()[3][3]);
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < 7; i++){
|
||||||
|
// for (int j = 0; j < 4; j++){
|
||||||
|
// assertEquals(availabilities[i][j], dbAvailabilities[i][j]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue