use of java.util.LinkedList in project mockito by mockito.
the class MocksCreationTest method shouldScreamWhenSpyCreatedWithWrongType.
@Test
public void shouldScreamWhenSpyCreatedWithWrongType() {
//given
List list = new LinkedList();
try {
//when
mock(List.class, withSettings().spiedInstance(list));
fail();
//then
} catch (MockitoException e) {
}
}
use of java.util.LinkedList in project killbill by killbill.
the class AccountResource method getInvoices.
/*
* ************************** INVOICES ********************************
*/
@TimedResource
@GET
@Path("/{accountId:" + UUID_PATTERN + "}/" + INVOICES)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Retrieve account invoices", response = InvoiceJson.class)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid account id supplied"), @ApiResponse(code = 404, message = "Account not found") })
public Response getInvoices(@PathParam("accountId") final String accountIdString, @QueryParam(QUERY_INVOICE_WITH_ITEMS) @DefaultValue("false") final boolean withItems, @QueryParam(QUERY_WITH_MIGRATION_INVOICES) @DefaultValue("false") final boolean withMigrationInvoices, @QueryParam(QUERY_UNPAID_INVOICES_ONLY) @DefaultValue("false") final boolean unpaidInvoicesOnly, @QueryParam(QUERY_AUDIT) @DefaultValue("NONE") final AuditMode auditMode, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException {
final TenantContext tenantContext = context.createContext(request);
// Verify the account exists
final UUID accountId = UUID.fromString(accountIdString);
accountUserApi.getAccountById(accountId, tenantContext);
final List<Invoice> invoices = unpaidInvoicesOnly ? new ArrayList<Invoice>(invoiceApi.getUnpaidInvoicesByAccountId(accountId, null, tenantContext)) : invoiceApi.getInvoicesByAccount(accountId, withMigrationInvoices, tenantContext);
final AccountAuditLogs accountAuditLogs = auditUserApi.getAccountAuditLogs(accountId, auditMode.getLevel(), tenantContext);
final List<InvoiceJson> result = new LinkedList<InvoiceJson>();
for (final Invoice invoice : invoices) {
result.add(new InvoiceJson(invoice, withItems, null, accountAuditLogs));
}
return Response.status(Status.OK).entity(result).build();
}
use of java.util.LinkedList in project head by mifos.
the class OfficeDaoHibernate method officeHierarchy.
private OfficeHierarchyDto officeHierarchy(OfficeBO office) {
List<OfficeHierarchyDto> childOfficeList = new LinkedList<OfficeHierarchyDto>();
Set<OfficeBO> children = office.getChildren();
for (OfficeBO child : children) {
childOfficeList.add(officeHierarchy(child));
}
Collections.sort(childOfficeList);
OfficeHierarchyDto hierarchy = new OfficeHierarchyDto(office.getOfficeId(), office.getOfficeName().trim(), office.getSearchId(), office.isActive(), childOfficeList);
return hierarchy;
}
use of java.util.LinkedList in project morphia by mongodb.
the class TestAsListPerf method driverQueryAndMorphiaConverter.
public double driverQueryAndMorphiaConverter(final int nbOfHits) {
final long start = System.nanoTime();
final List<DBObject> list = getDs().getDB().getCollection("Address").find().sort(new BasicDBObject("name", 1)).toArray();
final EntityCache entityCache = new DefaultEntityCache();
final List<Address> resultList = new LinkedList<Address>();
for (final DBObject dbObject : list) {
final Address address = getMorphia().fromDBObject(getDs(), Address.class, dbObject, entityCache);
resultList.add(address);
}
//ns -> ms
final long duration = (System.nanoTime() - start) / 1000000;
Assert.assertEquals(nbOfHits, resultList.size());
return (double) duration / nbOfHits;
}
use of java.util.LinkedList in project Signal-Android by WhisperSystems.
the class ContactAccessor method getNumbersForThreadSearchFilter.
public List<String> getNumbersForThreadSearchFilter(Context context, String constraint) {
LinkedList<String> numberList = new LinkedList<>();
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(Uri.withAppendedPath(Phone.CONTENT_FILTER_URI, Uri.encode(constraint)), null, null, null, null);
while (cursor != null && cursor.moveToNext()) {
numberList.add(cursor.getString(cursor.getColumnIndexOrThrow(Phone.NUMBER)));
}
} finally {
if (cursor != null)
cursor.close();
}
GroupDatabase.Reader reader = null;
GroupRecord record;
try {
reader = DatabaseFactory.getGroupDatabase(context).getGroupsFilteredByTitle(constraint);
while ((record = reader.getNext()) != null) {
numberList.add(record.getEncodedId());
}
} finally {
if (reader != null)
reader.close();
}
return numberList;
}
Aggregations