package io.keen.client.java;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;


/**
 * Tests AttemptCountingEventStore implementations.
 *
 * @author Simon Murtha Smith
 * @since 2.0.2
 */
public abstract class AttemptCountingEventStoreTestBase extends EventStoreTestBase {


    protected KeenAttemptCountingEventStore attemptCountingStore;


    @Before
    public void castStore() throws Exception {
        attemptCountingStore = (KeenAttemptCountingEventStore)store;
    }


    @Test
    public void storeAndGetEventAttempts() throws Exception {
        String attempts = "blargh";
        attemptCountingStore.setAttempts("project1", "collection1", attempts);
        assertEquals(attempts, attemptCountingStore.getAttempts("project1", "collection1"));
    }
}

@@ -83,44 +83,136 @@
 ort 
-static org.junit.Assert.assertEquals
+java.util.List;%0Aimport java.util.Map;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull
 ;%0A%0A%0A
@@ -798,16 +798,16 @@
 empts);%0A
-
         
@@ -896,11 +896,1208 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void getHandlesWithAttempts() throws Exception %7B%0A        // Add a couple events to the store.%0A        attemptCountingStore.store(%22project1%22, %22collection1%22, TEST_EVENT_1);%0A        attemptCountingStore.store(%22project1%22, %22collection2%22, TEST_EVENT_2);%0A%0A        // set some value for attempts.json. This is to ensure that setting attempts doesn't%0A        // interfere with getting handles%0A        attemptCountingStore.setAttempts(%22project1%22, %22collection1%22, %22%7B%7D%22);%0A%0A        // Get the handle map.%0A        Map%3CString, List%3CObject%3E%3E handleMap = attemptCountingStore.getHandles(%22project1%22);%0A        assertNotNull(handleMap);%0A        assertEquals(2, handleMap.size());%0A%0A        // Get the lists of handles.%0A        List%3CObject%3E handles1 = handleMap.get(%22collection1%22);%0A        assertNotNull(handles1);%0A        assertEquals(1, handles1.size());%0A        List%3CObject%3E handles2 = handleMap.get(%22collection2%22);%0A        assertNotNull(handles2);%0A        assertEquals(1, handles2.size());%0A%0A        // Validate the actual events.%0A        assertEquals(TEST_EVENT_1, attemptCountingStore.get(handles1.get(0)));%0A        assertEquals(TEST_EVENT_2, attemptCountingStore.get(handles2.get(0)));%0A    %7D
 %0A%7D%0A

Add test for attempt.json fix.