@Test(expected = InvalidOperationException.class) public void testStartAppsWithWrongCPUSpeed() throws InvalidOperationException { controller.setConfigurationReader(configurationReader); controller.startTablet(); TabletStatus status = controller.getCurrentStatus(); status.cpuSpeed = 1; controller.startApps(1, 1); }
@Test() public void testWithMock() throws InvalidOperationException { TabletStatus status = new TabletStatus(); status.isOverloaded = false; status.cpuSpeed = 1000; status.freeMemory = 3000; status.applications = 0; when(mockConfigurationReader.getStatus()).thenReturn(status); when(mockConfigurationReader.updateStatus()).thenReturn(true); controller.setConfigurationReader(mockConfigurationReader); TabletStatus returnStatus = controller.startApps(1, 1); Assert.assertEquals(false, returnStatus.isOverloaded); Assert.assertEquals(1055, returnStatus.cpuSpeed); Assert.assertEquals(2950, returnStatus.freeMemory); Assert.assertEquals(1, returnStatus.applications); }