### Question:
ImapPushState { public static ImapPushState parse(String pushState) { if (pushState == null || !pushState.startsWith(PUSH_STATE_PREFIX)) { return createDefaultImapPushState(); } String value = pushState.substring(PUSH_STATE_PREFIX_LENGTH); try { long newUidNext = Long.parseLong(value); return new ImapPushState(newUidNext); } catch (NumberFormatException e) { Timber.e(e, "Unable to part uidNext value %s", value); } return createDefaultImapPushState(); } ImapPushState(long uidNext); static ImapPushState parse(String pushState); @Override String toString(); final long uidNext; }### Answer:
@Test public void parse_withValidArgument() throws Exception { ImapPushState result = ImapPushState.parse("uidNext=42"); assertNotNull(result); assertEquals(42L, result.uidNext); }
@Test public void parse_withNullArgument_shouldReturnUidNextOfMinusOne() throws Exception { ImapPushState result = ImapPushState.parse(null); assertNotNull(result); assertEquals(-1L, result.uidNext); }
@Test public void parse_withEmptyArgument_shouldReturnUidNextOfMinusOne() throws Exception { ImapPushState result = ImapPushState.parse(""); assertNotNull(result); assertEquals(-1L, result.uidNext); }
@Test public void parse_withInvalidArgument_shouldReturnUidNextOfMinusOne() throws Exception { ImapPushState result = ImapPushState.parse("xyz"); assertNotNull(result); assertEquals(-1L, result.uidNext); }
@Test public void parse_withIncompleteArgument_shouldReturnUidNextOfMinusOne() throws Exception { ImapPushState result = ImapPushState.parse("uidNext="); assertNotNull(result); assertEquals(-1L, result.uidNext); }
@Test public void parse_withoutIntegerAsUidNext_shouldReturnUidNextOfMinusOne() throws Exception { ImapPushState result = ImapPushState.parse("uidNext=xyz"); assertNotNull(result); assertEquals(-1L, result.uidNext); }