Skip to content

Commit

Permalink
Fixing android studios lint suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtursKadikis committed Mar 11, 2019
1 parent f6bf089 commit 6b9cdd2
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 90 deletions.
2 changes: 1 addition & 1 deletion app-messaging-fcm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
defaultConfig {
applicationId "ly.count.android.demo.messaging_fcm"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 26
versionCode 1
versionName "1.0"

Expand Down
2 changes: 0 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':sdk')

implementation 'junit:junit:4.12'

//implementation 'com.google.android.gms:play-services-gcm:10.0.1'

//implementation 'ly.count.android:sdk:19.02.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.os.Bundle;
import android.view.View;

import junit.framework.Assert;

import ly.count.android.sdk.Countly;

@SuppressWarnings("UnusedParameters")
Expand Down Expand Up @@ -56,7 +54,7 @@ public void onClickCrashReporting04(View v) {

public void onClickCrashReporting05(View v) {
Countly.sharedInstance().addCrashBreadcrumb("Assert fail crash");
Assert.assertEquals(1, 0);
//Assert.assertEquals(1, 0);
}

public void onClickCrashReporting06(View v) {
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/layout/activity_example_crash_reporting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
android:onClick="onClickCrashReporting04"/>

<Button
android:text="@string/assert_fail"
android:id="@+id/button24"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/button24"
android:onClick="onClickCrashReporting05"/>
android:enabled="false"
android:onClick="onClickCrashReporting05"
android:text="@string/assert_fail" />

<Button
android:text="@string/kill"
Expand Down
2 changes: 1 addition & 1 deletion sdk-messaging-fcm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.novoda:bintray-release:0.8.1'
classpath 'com.novoda:bintray-release:0.9'
}
}

Expand Down
2 changes: 1 addition & 1 deletion sdk-messaging/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.novoda:bintray-release:0.8.1'
classpath 'com.novoda:bintray-release:0.9'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ConnectionProcessorTests {
String testDeviceId;

@Before
public void setUp() throws Exception {
public void setUp() {
mockStore = mock(CountlyStore.class);
mockDeviceId = mock(DeviceId.class);
connectionProcessor = new ConnectionProcessor("http://server", mockStore, mockDeviceId, null, null);
Expand Down Expand Up @@ -105,7 +105,7 @@ private static class TestInputStream extends InputStream {
boolean closed = false;

@Override
public int read() throws IOException {
public int read() {
return readCount++ < 1 ? 1 : -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ConnectionQueueTests {
final static long timestampAllowance = 150;

@Before
public void setUp() throws Exception {
public void setUp() {
freshConnQ = new ConnectionQueue();
connQ = new ConnectionQueue();
connQ.setAppKey("abcDeFgHiJkLmNoPQRstuVWxyz");
Expand Down Expand Up @@ -386,7 +386,7 @@ private Map<String, String> parseQueryParams(final String queryStr) {
final String urlStr = "http://server?" + queryStr;
final Uri uri = Uri.parse(urlStr);
final Set<String> queryParameterNames = uri.getQueryParameterNames();
final Map<String, String> queryParams = new HashMap<String, String>(queryParameterNames.size());
final Map<String, String> queryParams = new HashMap<>(queryParameterNames.size());
for (String paramName : queryParameterNames) {
queryParams.put(paramName, uri.getQueryParameter(paramName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public class CountlyStoreTests {
CountlyStore store;

@Before
public void setUp() throws Exception {
public void setUp() {
store = new CountlyStore(getContext());
store.clear();
}

@After
public void tearDown() throws Exception {
public void tearDown() {
store.clear();
}

Expand Down Expand Up @@ -157,7 +157,7 @@ public void testEventsList_singleEvent() {
event1.count = 1;
event1.dur = 10.0d;
store.addEvent(event1.key, event1.segmentation, null, null, event1.timestamp, event1.hour, event1.dow, event1.count, event1.sum, event1.dur);
final List<Event> expected = new ArrayList<Event>(1);
final List<Event> expected = new ArrayList<>(1);
expected.add(event1);
final List<Event> actual = store.eventsList();
assertEquals(expected, actual);
Expand All @@ -183,7 +183,7 @@ public void testEventsList_sortingOfMultipleEvents() {
store.addEvent(event1.key, event1.segmentation, null, null, event1.timestamp, event1.hour, event1.dow, event1.count, event1.sum, event1.dur);
store.addEvent(event2.key, event2.segmentation, null, null, event2.timestamp, event2.hour, event2.dow, event2.count, event2.sum, event2.dur);
store.addEvent(event3.key, event3.segmentation, null, null, event3.timestamp, event3.hour, event3.dow, event3.count, event3.sum, event3.dur);
final List<Event> expected = new ArrayList<Event>(3);
final List<Event> expected = new ArrayList<>(3);
expected.add(event2);
expected.add(event3);
expected.add(event1);
Expand All @@ -210,7 +210,7 @@ public void testEventsList_badJSON() {
final SharedPreferences prefs = getContext().getSharedPreferences("COUNTLY_STORE", Context.MODE_PRIVATE);
prefs.edit().putString("EVENTS", joinedEventsWithBadJSON).commit();

final List<Event> expected = new ArrayList<Event>(2);
final List<Event> expected = new ArrayList<>(2);
expected.add(event1);
expected.add(event2);
final List<Event> actual = store.eventsList();
Expand All @@ -236,7 +236,7 @@ public void testEventsList_EventFromJSONReturnsNull() {
final SharedPreferences prefs = getContext().getSharedPreferences("COUNTLY_STORE", Context.MODE_PRIVATE);
prefs.edit().putString("EVENTS", joinedEventsWithBadJSON).commit();

final List<Event> expected = new ArrayList<Event>(2);
final List<Event> expected = new ArrayList<>(2);
expected.add(event1);
expected.add(event2);
final List<Event> actual = store.eventsList();
Expand Down Expand Up @@ -326,7 +326,7 @@ public void testAddEvent() {
event1.count = 42;
event1.sum = 3.2;
event1.dur = 10.0d;
event1.segmentation = new HashMap<String, String>(2);
event1.segmentation = new HashMap<>(2);
event1.segmentation.put("segKey1", "segValue1");
event1.segmentation.put("segKey2", "segValue2");

Expand Down
34 changes: 22 additions & 12 deletions sdk/src/androidTest/java/ly/count/android/sdk/CountlyTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class CountlyTests {
Countly mCountly;

@Before
public void setUp() throws Exception {
public void setUp() {
final CountlyStore countlyStore = new CountlyStore(getContext());
countlyStore.clear();

Expand All @@ -57,7 +57,7 @@ public void setUp() throws Exception {
}

@After
public void tearDown() throws Exception {
public void tearDown() {
}

@Test
Expand Down Expand Up @@ -465,7 +465,7 @@ public void testRecordEvent_keyAndCountAndSum() {
public void testRecordEvent_keyAndSegmentationAndCount() {
final String eventKey = "eventKey";
final int count = 42;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", "segvalue1");
final Countly countly = spy(mCountly);
doNothing().when(countly).recordEvent(eventKey, segmentation, count, 0.0d);
Expand All @@ -478,7 +478,7 @@ public void testRecordEvent_initNotCalled() {
final String eventKey = "eventKey";
final int count = 42;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", "segvalue1");

try {
Expand All @@ -494,7 +494,7 @@ public void testRecordEvent_nullKey() {
final String eventKey = null;
final int count = 42;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", "segvalue1");

try {
Expand All @@ -511,7 +511,7 @@ public void testRecordEvent_emptyKey() {
final String eventKey = "";
final int count = 42;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", "segvalue1");

try {
Expand All @@ -527,7 +527,7 @@ public void testRecordEvent_countIsZero() {
final String eventKey = "";
final int count = 0;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", "segvalue1");

try {
Expand All @@ -543,7 +543,7 @@ public void testRecordEvent_countIsNegative() {
final String eventKey = "";
final int count = -1;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", "segvalue1");

try {
Expand All @@ -559,7 +559,7 @@ public void testRecordEvent_segmentationHasNullKey() {
final String eventKey = "";
final int count = 1;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put(null, "segvalue1");

try {
Expand All @@ -575,7 +575,7 @@ public void testRecordEvent_segmentationHasEmptyKey() {
final String eventKey = "";
final int count = 1;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("", "segvalue1");

try {
Expand All @@ -591,7 +591,7 @@ public void testRecordEvent_segmentationHasNullValue() {
final String eventKey = "";
final int count = 1;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", null);

try {
Expand All @@ -607,7 +607,7 @@ public void testRecordEvent_segmentationHasEmptyValue() {
final String eventKey = "";
final int count = 1;
final double sum = 3.0d;
final HashMap<String, String> segmentation = new HashMap<String, String>(1);
final HashMap<String, String> segmentation = new HashMap<>(1);
segmentation.put("segkey1", "");

try {
Expand All @@ -620,6 +620,7 @@ public void testRecordEvent_segmentationHasEmptyValue() {

//todo fix test, problem while mocking
/*
@Test
public void testRecordEvent() {
final String eventKey = "eventKey";
final int count = 42;
Expand All @@ -639,6 +640,7 @@ public void testRecordEvent() {
verify(countly).sendEventsIfNeeded();
}
@Test
public void testSendEventsIfNeeded_emptyQueue() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -653,6 +655,7 @@ public void testSendEventsIfNeeded_emptyQueue() {
verifyZeroInteractions(mockConnectionQueue);
}
@Test
public void testSendEventsIfNeeded_lessThanThreshold() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -667,6 +670,7 @@ public void testSendEventsIfNeeded_lessThanThreshold() {
verifyZeroInteractions(mockConnectionQueue);
}
@Test
public void testSendEventsIfNeeded_equalToThreshold() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -683,6 +687,7 @@ public void testSendEventsIfNeeded_equalToThreshold() {
verify(mockConnectionQueue, times(1)).recordEvents(eventData);
}
@Test
public void testSendEventsIfNeeded_moreThanThreshold() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -699,6 +704,7 @@ public void testSendEventsIfNeeded_moreThanThreshold() {
verify(mockConnectionQueue, times(1)).recordEvents(eventData);
}
@Test
public void testOnTimer_noActiveSession() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -711,6 +717,7 @@ public void testOnTimer_noActiveSession() {
verifyZeroInteractions(mockConnectionQueue, mockEventQueue);
}
@Test
public void testOnTimer_activeSession_emptyEventQueue() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -726,6 +733,7 @@ public void testOnTimer_activeSession_emptyEventQueue() {
verify(mockConnectionQueue, times(0)).recordEvents(anyString());
}
@Test
public void testOnTimer_activeSession_nonEmptyEventQueue() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -743,6 +751,7 @@ public void testOnTimer_activeSession_nonEmptyEventQueue() {
verify(mockConnectionQueue).recordEvents(eventData);
}
@Test
public void testOnTimer_activeSession_emptyEventQueue_sessionTimeUpdatesDisabled() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand All @@ -759,6 +768,7 @@ public void testOnTimer_activeSession_emptyEventQueue_sessionTimeUpdatesDisabled
verify(mockConnectionQueue, times(0)).recordEvents(anyString());
}
@Test
public void testOnTimer_activeSession_nonEmptyEventQueue_sessionTimeUpdatesDisabled() {
final ConnectionQueue mockConnectionQueue = mock(ConnectionQueue.class);
mCountly.setConnectionQueue(mockConnectionQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class EventQueueTests {
CountlyStore mMockCountlyStore;

@Before
public void setUp() throws Exception {
public void setUp() {

mMockCountlyStore = mock(CountlyStore.class);
mEventQueue = new EventQueue(mMockCountlyStore);
Expand All @@ -63,7 +63,7 @@ public void testRecordEvent() {
final int count = 42;
final double sum = 3.0d;
final double dur = 10.0d;
final Map<String, String> segmentation = new HashMap<String, String>(1);
final Map<String, String> segmentation = new HashMap<>(1);
final Map<String, Integer> segmentationInt = null;
final Map<String, Double> segmentationDouble = null;
final long timestamp = Countly.currentTimestampMs();
Expand All @@ -90,7 +90,7 @@ public void testSize() {

@Test
public void testEvents_emptyList() throws UnsupportedEncodingException {
final List<Event> eventsList = new ArrayList<Event>();
final List<Event> eventsList = new ArrayList<>();
when(mMockCountlyStore.eventsList()).thenReturn(eventsList);

final String expected = URLEncoder.encode("[]", "UTF-8");
Expand All @@ -101,7 +101,7 @@ public void testEvents_emptyList() throws UnsupportedEncodingException {

@Test
public void testEvents_nonEmptyList() throws UnsupportedEncodingException {
final List<Event> eventsList = new ArrayList<Event>();
final List<Event> eventsList = new ArrayList<>();
final Event event1 = new Event();
event1.key = "event1Key";
eventsList.add(event1);
Expand Down
Loading

0 comments on commit 6b9cdd2

Please sign in to comment.