@Test public void testSetNoDataLimit() throws PersistenceException { final long DATA_LIMIT = -1; ArgumentCaptor<String> keyArg = ArgumentCaptor.forClass(String.class); ArgumentCaptor<PersistentItem> itemArg = ArgumentCaptor.forClass(PersistentItem.class); attributesStore.setDataLimit(USER, DATA_LIMIT); verify(persistentStore).add(keyArg.capture(), itemArg.capture()); assertThat(keyArg.getValue(), is(PersistentStore.USER_ATTRIBUTE_TYPE)); assertThat( itemArg.getValue().getLongProperty(AttributesStore.DATA_USAGE_LIMIT_KEY), is(DATA_LIMIT)); }
@Test(expected = PersistenceException.class) public void testSetDataLimitNullUsername() throws PersistenceException { attributesStore.setDataLimit(null, LONG_5); }
@Test public void testSetInvalidDataLimit() throws PersistenceException { long dataUsage = -2L; // -1 indicates unlimited data limit attributesStore.setDataLimit(USER, dataUsage); verify(persistentStore, never()).add(anyString(), anyMap()); }