use of SQLDatabase.SQLDatabaseException.ManufacturerNotExist in project SmartCity-Market by TechnionYP5777.
the class RemoveManufacturerTest method removeManufacturerCriticalErrorTest.
@Test
public void removeManufacturerCriticalErrorTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_MANUFACTURER, new Gson().toJson(manufacturer, Manufacturer.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new CriticalError()).when(sqlDatabaseConnection).removeManufacturer(senderID, manufacturer);
} catch (ClientNotConnected | ManufacturerNotExist | ManufacturerStillUsed e1) {
fail();
} catch (CriticalError e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_ERR, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ManufacturerNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantEditNotExistedManufacturer.
@Test
public void testCantEditNotExistedManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
Manufacturer manufacturer = new Manufacturer(999, manufacturerName);
try {
sqlConnection.editManufacturer(null, manufacturer);
fail();
} catch (CriticalError | ClientNotConnected e) {
fail();
} catch (ManufacturerNotExist e) {
}
}
use of SQLDatabase.SQLDatabaseException.ManufacturerNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testCantRemoveNotExistedManufacturer.
@Test
public void testCantRemoveNotExistedManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
Manufacturer manufacturer = new Manufacturer(999, manufacturerName);
try {
sqlConnection.removeManufacturer(null, manufacturer);
fail();
} catch (CriticalError | ClientNotConnected | ManufacturerStillUsed e) {
fail();
} catch (ManufacturerNotExist e) {
}
}
use of SQLDatabase.SQLDatabaseException.ManufacturerNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testAddRemoveManufacturer.
@Test
public void testAddRemoveManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
String result = null;
Manufacturer manufacturer = null;
//test add ingredient
try {
String tempID = sqlConnection.addManufacturer(null, manufacturerName);
manufacturer = Serialization.deserialize(tempID, Manufacturer.class);
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected e) {
fail();
}
assert result != null;
HashSet<Manufacturer> set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
assert set.contains(manufacturer);
//test remove ingredient
try {
sqlConnection.removeManufacturer(null, manufacturer);
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist | ManufacturerStillUsed e) {
fail();
}
assert result != null;
set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
assert !set.contains(manufacturer);
}
use of SQLDatabase.SQLDatabaseException.ManufacturerNotExist in project SmartCity-Market by TechnionYP5777.
the class SQLDatabaseConnectionTest method testEditManufacturer.
@Test
public void testEditManufacturer() {
SQLDatabaseConnection sqlConnection = new SQLDatabaseConnection();
final String manufacturerName = "manydebug";
String result = null;
Manufacturer manufacturer = null;
try {
String tempID = sqlConnection.addManufacturer(null, manufacturerName);
manufacturer = Serialization.deserialize(tempID, Manufacturer.class);
manufacturer.setName("newManufacturer");
sqlConnection.editManufacturer(null, manufacturer);
result = sqlConnection.getManufacturersList(null);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist e) {
fail();
}
assert result != null;
HashSet<Manufacturer> set = Serialization.deserializeManufacturersHashSet(result);
assert set != null;
assert set.contains(manufacturer);
try {
sqlConnection.removeManufacturer(null, manufacturer);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist | ManufacturerStillUsed e) {
fail();
}
}
Aggregations