### Question:
TenantAdminDatastore extends Datastore implements DatastoreHasUpdate<TenantAdminItem>, DatastoreHasGet<TenantAdminItem> { @Override public TenantAdminItem update(final APIID unusedId, final Map<String, String> attributes) { final TenantAdminItem tenantAdminItem = new TenantAdminItem(); try { final boolean doPause = Boolean.parseBoolean(attributes.get(TenantAdminItem.ATTRIBUTE_IS_PAUSED)); tenantAdminItem.setId(apiSession.getTenantId()); if (!doPause) { getTenantManagementEngineClient().resumeTenant(); } else if (doPause) { getTenantManagementEngineClient().pauseTenant(); } tenantAdminItem.setIsPaused(doPause); return tenantAdminItem; } catch (final Exception e) { throw new APIException(e); } } TenantAdminDatastore(final APISession apiSession); @Override TenantAdminItem update(final APIID unusedId, final Map<String, String> attributes); @Override TenantAdminItem get(final APIID id);  }### Answer:
@Test public void testUpdateAlreadyInMaintenance() throws Exception { when(tenantAdministrationAPI.isPaused()).thenReturn(true); final APIID apiid = APIID.makeAPIID(1L); final TenantAdminItem tenantAdminItem = tenantAdminDatastore.update(apiid, mapOf(TenantAdminItem.ATTRIBUTE_IS_PAUSED, Boolean.TRUE.toString())); verify(tenantAdministrationAPI, times(1)).isPaused(); verify(tenantAdministrationAPI, times(0)).resume(); verify(tenantAdministrationAPI, times(0)).pause(); assertTrue(tenantAdminItem.isPaused()); }
@Test public void testUpdateAlreadyInAvailable() throws Exception { when(tenantAdministrationAPI.isPaused()).thenReturn(false); final APIID apiid = APIID.makeAPIID(1L); final TenantAdminItem tenantAdminItem = tenantAdminDatastore.update(apiid, mapOf(TenantAdminItem.ATTRIBUTE_IS_PAUSED, Boolean.FALSE.toString())); verify(tenantAdministrationAPI, times(1)).isPaused(); verify(tenantAdministrationAPI, times(0)).resume(); verify(tenantAdministrationAPI, times(0)).pause(); assertFalse(tenantAdminItem.isPaused()); }
@Test public void testUpdateGoInMaintenance() throws Exception { when(tenantAdministrationAPI.isPaused()).thenReturn(false); final APIID apiid = APIID.makeAPIID(1L); final TenantAdminItem tenantAdminItem = tenantAdminDatastore.update(apiid, mapOf(TenantAdminItem.ATTRIBUTE_IS_PAUSED, Boolean.TRUE.toString())); verify(tenantAdministrationAPI, times(1)).isPaused(); verify(tenantAdministrationAPI, times(1)).pause(); assertTrue(tenantAdminItem.isPaused()); }
@Test public void testUpdateGoInAvailable() throws Exception { when(tenantAdministrationAPI.isPaused()).thenReturn(true); final APIID apiid = APIID.makeAPIID(1L); final TenantAdminItem tenantAdminItem = tenantAdminDatastore.update(apiid, mapOf(TenantAdminItem.ATTRIBUTE_IS_PAUSED, Boolean.FALSE.toString())); verify(tenantAdministrationAPI, times(1)).isPaused(); verify(tenantAdministrationAPI, times(1)).resume(); assertFalse(tenantAdminItem.isPaused()); }