Skip to content

Commit

Permalink
PI-17835: Replacing all appearances of Lists.newArrayList(...) with C…
Browse files Browse the repository at this point in the history
…ollections.singletonList(...)
  • Loading branch information
AndresButelman authored and naponce committed Mar 25, 2020
1 parent a6d8c2a commit 96cce3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.appdirect.sdk.meteredusage.service;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.UUID;

Expand All @@ -22,7 +23,6 @@
import com.appdirect.sdk.meteredusage.model.MeteredUsageResponse;
import com.google.common.annotations.VisibleForTesting;
import com.google.gdata.util.common.base.Preconditions;
import com.google.inject.internal.Lists;
import retrofit2.Response;

@Slf4j
Expand All @@ -40,17 +40,17 @@ public MeteredUsageApiClientServiceImpl(DeveloperSpecificAppmarketCredentialsSup

@Override
public APIResult reportUsage(String baseUrl, String secretKey, String idempotentKey, MeteredUsageItem meteredUsageItem, boolean billable) {
return reportUsage(baseUrl, secretKey, idempotentKey, Lists.newArrayList(meteredUsageItem), billable);
return reportUsage(baseUrl, secretKey, idempotentKey, Collections.singletonList(meteredUsageItem), billable);
}

@Override
public APIResult reportUsage(String baseUrl, String secretKey, MeteredUsageItem meteredUsageItem, boolean billable) {
return reportUsage(baseUrl, secretKey, UUID.randomUUID().toString(), Lists.newArrayList(meteredUsageItem), billable);
return reportUsage(baseUrl, secretKey, UUID.randomUUID().toString(), Collections.singletonList(meteredUsageItem), billable);
}

@Override
public APIResult reportUsage(String baseUrl, String secretKey, MeteredUsageItem meteredUsageItem, boolean billable, String sourceType) {
return reportUsage(baseUrl, secretKey, UUID.randomUUID().toString(), Lists.newArrayList(meteredUsageItem), billable, sourceType);
return reportUsage(baseUrl, secretKey, UUID.randomUUID().toString(), Collections.singletonList(meteredUsageItem), billable, sourceType);
}

@Override
Expand All @@ -70,12 +70,12 @@ public APIResult reportUsage(String baseUrl, String secretKey, String idempotent

@Override
public APIResult reportUsage(String baseUrl, String idempotentKey, MeteredUsageItem meteredUsageItem, boolean billable, String secretKey, String secret) {
return reportUsage(baseUrl, idempotentKey, Lists.newArrayList(meteredUsageItem), billable, secretKey, secret, org.apache.commons.lang3.StringUtils.EMPTY);
return reportUsage(baseUrl, idempotentKey, Collections.singletonList(meteredUsageItem), billable, secretKey, secret, org.apache.commons.lang3.StringUtils.EMPTY);
}

@Override
public APIResult reportUsage(String baseUrl, MeteredUsageItem meteredUsageItem, boolean billable, String secretKey, String secret) {
return reportUsage(baseUrl, UUID.randomUUID().toString(), Lists.newArrayList(meteredUsageItem), billable, secretKey, secret, org.apache.commons.lang3.StringUtils.EMPTY);
return reportUsage(baseUrl, UUID.randomUUID().toString(), Collections.singletonList(meteredUsageItem), billable, secretKey, secret, org.apache.commons.lang3.StringUtils.EMPTY);
}

@Override
Expand All @@ -85,7 +85,7 @@ public APIResult reportUsage(String baseUrl, List<MeteredUsageItem> meteredUsage

@Override
public APIResult reportUsage(String baseUrl, MeteredUsageItem meteredUsageItem, boolean billable, String secretKey, String secret, String sourceType) {
return reportUsage(baseUrl, UUID.randomUUID().toString(), Lists.newArrayList(meteredUsageItem), billable, secretKey, secret, sourceType);
return reportUsage(baseUrl, UUID.randomUUID().toString(), Collections.singletonList(meteredUsageItem), billable, secretKey, secret, sourceType);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.appdirect.sdk.meteredusage.mother;

import java.util.Collections;

import com.appdirect.sdk.meteredusage.model.MeteredUsageItem;
import com.appdirect.sdk.utils.ConstantUtils;
import com.google.inject.internal.Lists;

public class MeteredUsageItemMother {
public static MeteredUsageItem.MeteredUsageItemBuilder basic() {
return MeteredUsageItem.builder()
.accountId(ConstantUtils.ACCOUNT_ID)
.usageList(Lists.newArrayList(UsageItemMother.basic().build()));
.usageList(Collections.singletonList(UsageItemMother.basic().build()));
}

public static MeteredUsageItem.MeteredUsageItemBuilder withSubscriptionId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.appdirect.sdk.meteredusage.model.MeteredUsageResponse;
import com.appdirect.sdk.meteredusage.mother.MeteredUsageItemMother;
import com.appdirect.sdk.utils.ConstantUtils;
import com.google.inject.internal.Lists;
import okhttp3.MediaType;
import okhttp3.ResponseBody;
import okio.Buffer;
Expand Down Expand Up @@ -65,7 +64,7 @@ public void testBillUsage_noErrors() {
MeteredUsageApi meteredUsageApi = mock(MeteredUsageApi.class);
Response<MeteredUsageResponse> response = buildResponse(requestAccepted);
Call<MeteredUsageResponse> call = new RetrofitCallStub(response).getCall();
List<MeteredUsageItem> items = Lists.newArrayList(meteredUsageItem);
List<MeteredUsageItem> items = Collections.singletonList(meteredUsageItem);

doReturn(call).when(meteredUsageApi).meteredUsageCall(any());
doReturn(meteredUsageApi).when(meteredUsageApiClientService).createMeteredUsageApi(ConstantUtils.BASE_URL, ConstantUtils.CONSUMER_KEY, ConstantUtils.CONSUMER_SECRET);
Expand All @@ -85,7 +84,7 @@ public void testSourceTypeUsage_noErrors() {
MeteredUsageApi meteredUsageApi = mock(MeteredUsageApi.class);
Response<MeteredUsageResponse> response = buildResponse(requestAccepted);
Call<MeteredUsageResponse> call = new RetrofitCallStub(response).getCall();
List<MeteredUsageItem> items = Lists.newArrayList(meteredUsageItem);
List<MeteredUsageItem> items = Collections.singletonList(meteredUsageItem);

doReturn(call).when(meteredUsageApi).meteredUsageCall(any());
doReturn(meteredUsageApi).when(meteredUsageApiClientService).createMeteredUsageApi(ConstantUtils.BASE_URL, ConstantUtils.CONSUMER_KEY, ConstantUtils.CONSUMER_SECRET);
Expand All @@ -105,7 +104,7 @@ public void testBillUsage_unsuccessfulCall() {
MeteredUsageApi meteredUsageApi = mock(MeteredUsageApi.class);
Response<MeteredUsageResponse> response = buildResponse(httpStatus, ErrorCode.UNKNOWN_ERROR.toString());
Call<MeteredUsageResponse> call = new RetrofitCallStub(response).getCall();
List<MeteredUsageItem> items = Lists.newArrayList(meteredUsageItem);
List<MeteredUsageItem> items = Collections.singletonList(meteredUsageItem);

doReturn(call).when(meteredUsageApi).meteredUsageCall(any());
doReturn(meteredUsageApi).when(meteredUsageApiClientService).createMeteredUsageApi(ConstantUtils.BASE_URL, ConstantUtils.CONSUMER_KEY, ConstantUtils.CONSUMER_SECRET);
Expand All @@ -125,7 +124,7 @@ public void testBillUsageNullSecret_noErrors() {
MeteredUsageApi meteredUsageApi = mock(MeteredUsageApi.class);
Response<MeteredUsageResponse> response = buildResponse(requestAccepted);
Call<MeteredUsageResponse> call = new RetrofitCallStub(response).getCall();
List<MeteredUsageItem> items = Lists.newArrayList(meteredUsageItem);
List<MeteredUsageItem> items = Collections.singletonList(meteredUsageItem);

doReturn(call).when(meteredUsageApi).meteredUsageCall(any());
doReturn(meteredUsageApi).when(meteredUsageApiClientService).createMeteredUsageApi(ConstantUtils.BASE_URL, ConstantUtils.CONSUMER_KEY, null);
Expand All @@ -145,7 +144,7 @@ public void testBillUsageNullSecret_unsuccessfulCall() {
MeteredUsageApi meteredUsageApi = mock(MeteredUsageApi.class);
Response<MeteredUsageResponse> response = buildResponse(httpStatus, ErrorCode.UNKNOWN_ERROR.toString());
Call<MeteredUsageResponse> call = new RetrofitCallStub(response).getCall();
List<MeteredUsageItem> items = Lists.newArrayList(meteredUsageItem);
List<MeteredUsageItem> items = Collections.singletonList(meteredUsageItem);

doReturn(call).when(meteredUsageApi).meteredUsageCall(any());
doReturn(meteredUsageApi).when(meteredUsageApiClientService).createMeteredUsageApi(ConstantUtils.BASE_URL, ConstantUtils.CONSUMER_KEY, null);
Expand Down

0 comments on commit 96cce3a

Please sign in to comment.