Search in sources :

Example 1 with DataUsage

use of org.codice.ddf.resourcemanagement.usage.service.DataUsage in project ddf by codice.

the class TestDataUsage method setUp.

@Before
public void setUp() throws PersistenceException {
    attributesStore = mock(AttributesStore.class);
    persistentStore = mock(PersistentStore.class);
    userList = generateUserList();
    when(attributesStore.getAllUsers()).thenReturn(userList);
    doAnswer((InvocationOnMock invocationOnMock) -> {
        Object[] args = invocationOnMock.getArguments();
        String user = (String) args[0];
        long dataUsage = (long) args[1];
        for (Map<String, Object> map : userList) {
            if (map.get(USER_TXT).equals(user)) {
                map.put(DATA_LIMIT, dataUsage);
            }
        }
        return null;
    }).when(attributesStore).setDataLimit(anyString(), anyLong());
    dataUsage = new DataUsage(attributesStore, persistentStore);
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) PersistentStore(org.codice.ddf.persistence.PersistentStore) Matchers.anyString(org.mockito.Matchers.anyString) DataUsage(org.codice.ddf.resourcemanagement.usage.service.DataUsage) AttributesStore(org.codice.ddf.persistence.attributes.AttributesStore) Before(org.junit.Before)

Aggregations

PersistentStore (org.codice.ddf.persistence.PersistentStore)1 AttributesStore (org.codice.ddf.persistence.attributes.AttributesStore)1 DataUsage (org.codice.ddf.resourcemanagement.usage.service.DataUsage)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1