use of CommandHandler.CommandExecuter in project SmartCity-Market by TechnionYP5777.
the class RegisterNewWorkerTest method registerNewWorkerClientNotConnectedTest.
@Test
public void registerNewWorkerClientNotConnectedTest() {
int senderID = 1;
String command = new CommandWrapper(senderID, CommandDescriptor.REGISTER_NEW_WORKER, new Gson().toJson(worker, Login.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ClientNotConnected()).when(sqlDatabaseConnection).addWorker(senderID, worker, worker.getForgetPassword());
} catch (CriticalError | ClientAlreadyExist e) {
fail();
} catch (ClientNotConnected __) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_SENDER_IS_NOT_CONNECTED, out.getResultDescriptor());
}
use of CommandHandler.CommandExecuter in project SmartCity-Market by TechnionYP5777.
the class RegisterNewWorkerTest method registerNewWorkerClientAlreadyExistTest.
@Test
public void registerNewWorkerClientAlreadyExistTest() {
int senderID = 1;
String command = new CommandWrapper(senderID, CommandDescriptor.REGISTER_NEW_WORKER, new Gson().toJson(worker, Login.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doThrow(new ClientAlreadyExist()).when(sqlDatabaseConnection).addWorker(senderID, worker, worker.getForgetPassword());
} catch (CriticalError | ClientNotConnected e) {
fail();
} catch (ClientAlreadyExist __) {
/* success */
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_USERNAME_ALREADY_EXISTS, out.getResultDescriptor());
}
use of CommandHandler.CommandExecuter in project SmartCity-Market by TechnionYP5777.
the class RegisterNewWorkerTest method registerNewWorkerSuccessfulTest.
@Test
public void registerNewWorkerSuccessfulTest() {
int senderID = 1;
String command = new CommandWrapper(senderID, CommandDescriptor.REGISTER_NEW_WORKER, new Gson().toJson(worker, Login.class)).serialize();
CommandExecuter commandExecuter = new CommandExecuter(command);
CommandWrapper out;
try {
Mockito.doNothing().when(sqlDatabaseConnection).addWorker(senderID, worker, worker.getForgetPassword());
} catch (CriticalError | ClientAlreadyExist | ClientNotConnected e) {
fail();
}
out = commandExecuter.execute(sqlDatabaseConnection);
assertEquals(ResultDescriptor.SM_OK, out.getResultDescriptor());
}
use of CommandHandler.CommandExecuter 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 CommandHandler.CommandExecuter 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());
}
Aggregations