@Test public void testCalculateStatusChargingState() { PowerMockito.mockStatic(SP.class); when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(false); EventChargingState ev = new EventChargingState(true); assertTrue(sut.calculateStatus(ev)); ev = new EventChargingState(false); assertTrue(sut.calculateStatus(ev)); when(SP.getBoolean(anyInt(), anyBoolean())).thenReturn(true); ev = new EventChargingState(true); assertTrue(sut.calculateStatus(ev)); ev = new EventChargingState(false); assertTrue(!sut.calculateStatus(ev)); }
boolean calculateStatus(final EventChargingState ev) { boolean chargingOnly = SP.getBoolean(R.string.key_ns_chargingonly, false); boolean newAllowedState = true; if (!ev.isCharging() && chargingOnly) { newAllowedState = false; } return newAllowedState; }
NsClientReceiverDelegate { boolean calculateStatus(final EventChargingState ev) { boolean chargingOnly = SP.getBoolean(R.string.key_ns_chargingonly, false); boolean newAllowedState = true; if (!ev.isCharging() && chargingOnly) { newAllowedState = false; } return newAllowedState; } }
NsClientReceiverDelegate { boolean calculateStatus(final EventChargingState ev) { boolean chargingOnly = SP.getBoolean(R.string.key_ns_chargingonly, false); boolean newAllowedState = true; if (!ev.isCharging() && chargingOnly) { newAllowedState = false; } return newAllowedState; }  }
NsClientReceiverDelegate { boolean calculateStatus(final EventChargingState ev) { boolean chargingOnly = SP.getBoolean(R.string.key_ns_chargingonly, false); boolean newAllowedState = true; if (!ev.isCharging() && chargingOnly) { newAllowedState = false; } return newAllowedState; }   }
NsClientReceiverDelegate { boolean calculateStatus(final EventChargingState ev) { boolean chargingOnly = SP.getBoolean(R.string.key_ns_chargingonly, false); boolean newAllowedState = true; if (!ev.isCharging() && chargingOnly) { newAllowedState = false; } return newAllowedState; }    }