Search in sources :

Example 61 with LinkedList

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) {
    }
}
Also used : MockitoException(org.mockito.exceptions.base.MockitoException) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 62 with LinkedList

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();
}
Also used : Invoice(org.killbill.billing.invoice.api.Invoice) InvoiceJson(org.killbill.billing.jaxrs.json.InvoiceJson) TenantContext(org.killbill.billing.util.callcontext.TenantContext) UUID(java.util.UUID) AccountAuditLogs(org.killbill.billing.util.audit.AccountAuditLogs) LinkedList(java.util.LinkedList) Path(javax.ws.rs.Path) TimedResource(org.killbill.commons.metrics.TimedResource) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 63 with LinkedList

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;
}
Also used : OfficeHierarchyDto(org.mifos.dto.domain.OfficeHierarchyDto) OfficeBO(org.mifos.customers.office.business.OfficeBO) LinkedList(java.util.LinkedList)

Example 64 with LinkedList

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;
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) EntityCache(org.mongodb.morphia.mapping.cache.EntityCache) DefaultEntityCache(org.mongodb.morphia.mapping.cache.DefaultEntityCache) DefaultEntityCache(org.mongodb.morphia.mapping.cache.DefaultEntityCache) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject) LinkedList(java.util.LinkedList)

Example 65 with LinkedList

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;
}
Also used : GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) MergeCursor(android.database.MergeCursor) Cursor(android.database.Cursor) GroupRecord(org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)10512 Test (org.junit.Test)1487 List (java.util.List)1463 HashMap (java.util.HashMap)1371 ArrayList (java.util.ArrayList)1313 Map (java.util.Map)871 IOException (java.io.IOException)800 File (java.io.File)695 HashSet (java.util.HashSet)605 LinkedHashMap (java.util.LinkedHashMap)382 GenericValue (org.apache.ofbiz.entity.GenericValue)296 Iterator (java.util.Iterator)277 Set (java.util.Set)255 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)232 Date (java.util.Date)222 Collection (java.util.Collection)201 Delegator (org.apache.ofbiz.entity.Delegator)162 Locale (java.util.Locale)158 URL (java.net.URL)154 BufferedReader (java.io.BufferedReader)146