Java Code Examples for org.eclipse.collections.impl.list.mutable.FastList#newListWith()

The following examples show how to use org.eclipse.collections.impl.list.mutable.FastList#newListWith() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiThreadedBatchProcessorTest.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testNoShards()
{
    List deepFetches = FastList.newListWith(OrderFinder.items(), OrderFinder.orderStatus());

    OrderConsumer consumer = new OrderConsumer();

    MultiThreadedBatchProcessor<Order, OrderList> mtbp = new MultiThreadedBatchProcessor<Order, OrderList>(
            OrderFinder.getFinderInstance(),
            OrderFinder.orderId().greaterThanEquals(1000),
            (List<Navigation<Order>>) deepFetches,
            consumer,
            null);
    mtbp.setBatchSize(77);
    mtbp.process();
    assertEquals(1100, consumer.count.get());
}
 
Example 2
Source File: ExercisesMTLoader.java    From reladomo-kata with Apache License 2.0 6 votes vote down vote up
private static MutableList<Employee> getFileList()
{
    Timestamp currentTimestamp = Timestamp.valueOf("2015-02-01 00:00:00.0");

    Employee mary = new Employee(currentTimestamp, 1, "Mary", "Lamb", 26);
    Employee bob = new Employee(currentTimestamp, 2, "Bob", "Smith", 29);
    Employee ted = new Employee(currentTimestamp, 3, "Ted", "Smith", 33);
    Employee jake = new Employee(currentTimestamp, 4, "Jake", "Snake", 42);
    Employee barry = new Employee(currentTimestamp, 5, "Barry", "Bird", 28);
    Employee terry = new Employee(currentTimestamp, 6, "Terry", "Chase", 19);
    Employee harry = new Employee(currentTimestamp, 7, "Harry", "White", 22);
    Employee john = new Employee(currentTimestamp, 8, "John", "Doe", 45);
    Employee jane = new Employee(currentTimestamp, 9, "Jane", "Wilson", 28);

    return FastList.newListWith(mary, bob, ted, jake, barry, terry, harry, john, jane);
}
 
Example 3
Source File: FlatCollectUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@Before
public void setup() {
    String address1 = "73 Pacific St., Forest Hills, NY 11375";
    String address2 = "93 Bayport Ave., South Richmond Hill, NY 11419";
    String address3 = "548 Market St, San Francisco, CA 94104";
    String address4 = "8605 Santa Monica Blvd, West Hollywood, CA 90069";

    this.addresses1 = FastList.newListWith(address1, address2);
    this.addresses2 = FastList.newListWith(address3, address4);
    Student student1 = new Student("John", "Hopkins", addresses1);
    Student student2 = new Student("George", "Adams", addresses2);
    this.addresses2 = FastList.newListWith(address3, address4);
    this.students = FastList.newListWith(student1, student2);
    this.expectedAddresses = new ArrayList<>();
    this.expectedAddresses.add("73 Pacific St., Forest Hills, NY 11375");
    this.expectedAddresses.add("93 Bayport Ave., South Richmond Hill, NY 11419");
    this.expectedAddresses.add("548 Market St, San Francisco, CA 94104");
    this.expectedAddresses.add("8605 Santa Monica Blvd, West Hollywood, CA 90069");
}
 
Example 4
Source File: ProcessingDateMilestonedTopLevelLoaderFactory.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public List<TaskOperationDefinition> buildRefreshTaskDefinitions(CacheLoaderContext context, Operation loadOperation)
{
    Timestamp start = context.getRefreshInterval().getStart();
    Timestamp end = context.getRefreshInterval().getEnd();

    final Operation inGreaterThenStart = this.getProcessingDateAttribute().getFromAttribute().greaterThanEquals(start);
    final Operation inLessThenEnd = this.getProcessingDateAttribute().getFromAttribute().lessThanEquals(end);
    final Operation loadChangedInZ = inGreaterThenStart.and(inLessThenEnd);

    final Operation outGreaterThenStart = this.getProcessingDateAttribute().getToAttribute().greaterThanEquals(start);
    final Operation outLessThenEnd = this.getProcessingDateAttribute().getToAttribute().lessThanEquals(end);
    final Operation loadChangedOutZ = outGreaterThenStart.and(outLessThenEnd);

    return FastList.newListWith(
            new TaskOperationDefinition(loadChangedInZ, true),
            new TaskOperationDefinition(loadChangedOutZ, false)
    );
}
 
Example 5
Source File: ExercisesRelationships.java    From reladomo-kata with Apache License 2.0 6 votes vote down vote up
@Test
public void testQ4()
{
    CustomerAccountList accountsBefore = CustomerAccountFinder.findMany(CustomerAccountFinder.all());
    CustomerList customersBefore = CustomerFinder.findMany(CustomerFinder.all());
    accountsBefore.forceResolve(); //to get this list resolved before we add the new customer.
    customersBefore.forceResolve();

    MutableList<Pair<String, String>> accountDescriptionAndTypePairs = FastList.newListWith(
            Tuples.pair("Tom's saving Account", "Savings"),
            Tuples.pair("Tom's running Account", "Running")
    );

    this.addCustomerAccounts("Tom Jones", "UK", accountDescriptionAndTypePairs);

    CustomerAccountList accountsAfter = CustomerAccountFinder.findMany(CustomerAccountFinder.all());
    CustomerList customersAfter = CustomerFinder.findMany(CustomerFinder.all());

    Assert.assertEquals(1, customersAfter.size() - customersBefore.size());
    Assert.assertEquals(2, accountsAfter.size() - accountsBefore.size());

    Customer tom = CustomerFinder.findOne(CustomerFinder.name().eq("Tom Jones"));
    CustomerAccountList tomsAccounts = new CustomerAccountList(CustomerAccountFinder.customerId().eq(tom.getCustomerId()));
    Verify.assertSize(2, tomsAccounts);
}
 
Example 6
Source File: CacheLoaderEngineTest.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testLoadWithPrerequisites()
    {
        CacheLoaderContext context = new CacheLoaderContext(new CacheLoaderManagerImpl(), FastList.newListWith(BUSINESS_DATE));
        CacheLoaderEngine engine = context.getEngine();
        engine.setConfigValues(new ConfigValues(1, 1, true, 2, 45, 1200));

        Operation op1 = LewProductFinder.region().eq(NYK_REGION).and(LewProductFinder.businessDate().eq(BUSINESS_DATE)).and(LewProductFinder.processingDate().equalsEdgePoint());
        LoadingTaskRunner loadingTask1 = new LoadingTaskRunner(engine, "nylew", createLoadingTask(LewProductFinder.class, op1), LoadingTaskRunner.State.WAITING_FOR_PREREQUISITES);
        engine.addTaskToLoadAndSetupThreadPool(loadingTask1);

        Operation op2 = LewContractFinder.region().eq(NYK_REGION).and(LewContractFinder.businessDate().eq(BUSINESS_DATE)).and(LewContractFinder.processingDate().equalsEdgePoint());
        LoadingTaskRunner loadingTask2 = new LoadingTaskRunner(engine, "nylew", createLoadingTask(LewContractFinder.class, op2), LoadingTaskRunner.State.WAITING_FOR_PREREQUISITES);
        engine.addTaskToLoadAndSetupThreadPool(loadingTask2);
        loadingTask1.addPrerequisite(loadingTask2);

        assertEquals(0, LewContractFinder.findMany(LewContractFinder.businessDate().equalsEdgePoint().and(LewContractFinder.processingDate().equalsEdgePoint())).size());
        assertEquals(0, LewProductFinder.findMany(LewProductFinder.businessDate().equalsEdgePoint().and(LewProductFinder.processingDate().equalsEdgePoint())).size());

        engine.waitUntilAllTasksCompleted();

        assertEquals(3, LewContractFinder.findMany(LewContractFinder.businessDate().equalsEdgePoint().and(LewContractFinder.processingDate().equalsEdgePoint())).size());
        assertEquals(7, LewProductFinder.findMany(LewProductFinder.businessDate().equalsEdgePoint().and(LewProductFinder.processingDate().equalsEdgePoint())).size());

        LoadingTaskMonitor productsInfo = engine.getTaskMonitors().get(0);
        LoadingTaskMonitor contractInfo = engine.getTaskMonitors().get(1);

//        assertTrue(contractInfo.getStartTime() + "<=" + contractInfo.getFinishTime(), contractInfo.getStartTime() <= contractInfo.getFinishTime());
//        assertTrue(contractInfo.getFinishTime() + "<=" + productsInfo.getStartTime(), contractInfo.getFinishTime() <= productsInfo.getStartTime());
//        assertTrue(contractInfo.getSql().indexOf("select ") > 0);
    }
 
Example 7
Source File: ExercisesAdvancedFinder.java    From reladomo-kata with Apache License 2.0 5 votes vote down vote up
@Test
public void testQ2()
{
    MutableList accountNameAndTypes = FastList.newListWith(
            Tuples.twin("John's Saving Account 2", "Savings"),
            Tuples.twin("My Account", "Running"),
            Tuples.twin("No customer Account", "Virtual")
    );

    CustomerAccountList accounts = this.getAccountsBasedOnTuples(accountNameAndTypes);

    Verify.assertListsEqual(FastList.newListWith(300, 500, 600),
            accounts.asEcList().collect(CustomerAccountFinder.accountId()));
}
 
Example 8
Source File: ZipWithIndexUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void whenZip_thenCorrect() {
    MutableList<String> cars = FastList.newListWith("Porsche", "Volvo", "Toyota");
    MutableList<Pair<String, Integer>> pairs = cars.zipWithIndex();

    Assertions.assertThat(pairs).containsExactlyElementsOf(this.expectedPairs);
}
 
Example 9
Source File: DetectPatternUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void getList() {
    this.list = FastList.newListWith(1, 8, 5, 41, 31, 17, 23, 38);
}
 
Example 10
Source File: AllSatisfyPatternUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void getList() {
    this.list = FastList.newListWith(1, 8, 5, 41, 31, 17, 23, 38);
}
 
Example 11
Source File: DateLoadClusterTest.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public void testSingleAndMultiMixture() throws Exception
{
    List<Timestamp> inputDates = FastList.newListWith(PBD2, PYE, PPBD1, PPYE, PPBD2, PBD1);
    assertEquals(FastList.newListWith(newDateCluster(PPYE), newDateCluster(PYE), newDateCluster(PPBD2, PBD2), newDateCluster(PPBD1, PBD1)),
            DateClusterCreator.createMultiDateClusters(inputDates));
}
 
Example 12
Source File: RelationshipMultiExtractor.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public RelationshipMultiExtractorBuilder(Attribute... leftAttributes)
{
    this.leftAttributes = FastList.newListWith(leftAttributes);
}
 
Example 13
Source File: RelationshipMultiExtractor.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public RelationshipMultiExtractor withExtractors(Extractor... extractors)
{
    return new RelationshipMultiExtractor(leftAttributes, FastList.newListWith(extractors));
}
 
Example 14
Source File: DateLoadClusterTest.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public void testSingleDateCreation() throws Exception
{
    List<Timestamp> inputDates = FastList.newListWith(PBD2, PYE, PPBD1, PPYE, PPBD2, PBD1);
    assertEquals(FastList.newListWith(newDateCluster(PPYE), newDateCluster(PYE), newDateCluster(PPBD2), newDateCluster(PBD2), newDateCluster(PPBD1), newDateCluster(PBD1)),
            DateClusterCreator.createSingleDateClusters(inputDates));
}
 
Example 15
Source File: BusinessDateFilterTest.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public BooleanFilter createCacheFilterOfDatesToDrop(Timestamp businessDate)
{
    return new KeepOnlySpecifiedDatesFilter(LewContractFinder.businessDate(), FastList.newListWith(DATE3));
}
 
Example 16
Source File: DateLoadClusterTest.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public void testEmptyInputListResultsInEmptyOutputList() throws Exception
{
    List<Timestamp> inputDates = FastList.newListWith();
    List<DateCluster> cluster = DateClusterCreator.createMultiDateClusters(inputDates);
    assertEquals(FastList.newListWith(), cluster);
}
 
Example 17
Source File: DateLoadClusterTest.java    From reladomo with Apache License 2.0 4 votes vote down vote up
private static DateCluster newDateCluster(Timestamp... dates)
{
    return new DateCluster(FastList.newListWith(dates));
}
 
Example 18
Source File: VendorTestConnectionManager.java    From reladomo with Apache License 2.0 4 votes vote down vote up
@Override
protected Collection<XAConnectionManager> getAllConnectionManagers()
{
    return FastList.newListWith(this.connectionManager);
}
 
Example 19
Source File: AnySatisfyPatternUnitTest.java    From tutorials with MIT License 4 votes vote down vote up
@Before
public void getList() {
    this.list = FastList.newListWith(1, 8, 5, 41, 31, 17, 23, 38);
}
 
Example 20
Source File: DateLoadClusterTest.java    From reladomo with Apache License 2.0 4 votes vote down vote up
public void testMultipleMultiBusinessDateClusters() throws Exception
{
    List<Timestamp> inputDates = FastList.newListWith(PBD2, PPBD1, PPBD2, PBD1);
    assertEquals(FastList.newListWith(newDateCluster(PPBD2, PBD2), newDateCluster(PPBD1, PBD1)), DateClusterCreator.createMultiDateClusters(inputDates));
}