use of SQLDatabase.SQLDatabaseException.ManufacturerStillUsed in project SmartCity-Market by TechnionYP5777.
the class RemoveManufacturerTest method removeManufacturerSuccessfulTest.
@Test
public void removeManufacturerSuccessfulTest() {
String command = new CommandWrapper(senderID, CommandDescriptor.REMOVE_MANUFACTURER, new Gson().toJson(manufacturer, Manufacturer.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doNothing().when(sqlDatabaseConnection).removeManufacturer(senderID, manufacturer);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist | ManufacturerStillUsed e1) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_OK, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ManufacturerStillUsed in project SmartCity-Market by TechnionYP5777.
the class RemoveManufacturerTest method removeManufacturerClientNotConnectedTest.
@Test
public void removeManufacturerClientNotConnectedTest() {
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 ClientNotConnected()).when(sqlDatabaseConnection).removeManufacturer(senderID, manufacturer);
} catch (CriticalError | ManufacturerNotExist | ManufacturerStillUsed e1) {
fail();
} catch (ClientNotConnected e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_SENDER_IS_NOT_CONNECTED, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ManufacturerStillUsed in project SmartCity-Market by TechnionYP5777.
the class RemoveManufacturerTest method removeManufacturerManufacturerNotExistTest.
@Test
public void removeManufacturerManufacturerNotExistTest() {
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 ManufacturerNotExist()).when(sqlDatabaseConnection).removeManufacturer(senderID, manufacturer);
} catch (CriticalError | ClientNotConnected | ManufacturerStillUsed e1) {
fail();
} catch (ManufacturerNotExist e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.PARAM_ID_IS_NOT_EXIST, out.getResultDescriptor());
}
use of SQLDatabase.SQLDatabaseException.ManufacturerStillUsed in project SmartCity-Market by TechnionYP5777.
the class RemoveManufacturerTest method removeManufacturerManufacturerStillUsedTest.
@Test
public void removeManufacturerManufacturerStillUsedTest() {
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 ManufacturerStillUsed()).when(sqlDatabaseConnection).removeManufacturer(senderID, manufacturer);
} catch (CriticalError | ClientNotConnected | ManufacturerNotExist e1) {
fail();
} catch (ManufacturerStillUsed e) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_MANUFACTURER_STILL_IN_USE, out.getResultDescriptor());
}
Aggregations