当前位置: 首页>>代码示例>>Java>>正文


Java Lists类代码示例

本文整理汇总了Java中org.python.google.common.collect.Lists的典型用法代码示例。如果您正苦于以下问题:Java Lists类的具体用法?Java Lists怎么用?Java Lists使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Lists类属于org.python.google.common.collect包,在下文中一共展示了Lists类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSystemEvents

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void testSystemEvents() {
    Engine engine = DefaultEngine.builder().config("examples/core/system_events.xml").build();
    engine.startup();

    try {
        await().atMost(60, TimeUnit.SECONDS)
                .until(() -> engine.getOperations().getVariable(Number.class, "countA").intValue() >= 5
                        && engine.getOperations().getVariable(Number.class, "countB").intValue() >= 1
                        && engine.getOperations().getVariable(List.class, "listC").size() >= 7);

        assertEquals(5, engine.getOperations().getVariable(Number.class, "countA").intValue());
        assertEquals(1, engine.getOperations().getVariable(Number.class, "countB").intValue());
        assertEquals(Lists.newArrayList("startup", "x", "e", "e", "e", "e", "e"),
                engine.getOperations().getVariable(List.class, "listC"));

        assertFalse(engine.isError());
    } finally {
        engine.shutdown();
    }
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:22,代码来源:SystemEventsTest.java

示例2: createReaderInput

import org.python.google.common.collect.Lists; //导入依赖的package包/类
private void createReaderInput(int count)
{
  String address = "\"address\":{" + "\"streetAddress\": \"21 2nd Street\"," + "\"city\": \"New York\","
      + "\"state\": \"NY\"," + "\"postalCode\": \"10021\"}";
  recordList = Lists.newArrayList();
  while (count > 0) {
    StringBuilder sb = new StringBuilder();
    sb.append("{").append("\"id\"").append(":").append(count).append(",");
    sb.append("\"name\":").append("\"").append("name-" + count).append("\"").append(",");
    sb.append("\"Elective-0\":").append("\"").append("elective-" + count * 1).append("\"").append(",");
    sb.append("\"Elective-1\":").append("\"").append("elective-" + count * 2).append("\"").append(",");
    sb.append("\"Elective-2\":").append("\"").append("elective-" + count * 3).append("\"").append(",");
    sb.append("\"Elective-3\":").append("\"").append("elective-" + count * 4).append("\"").append(",");
    sb.append("\"gpa\":").append(count * 2.0).append(",");
    sb.append(address).append("}");
    count--;
    recordList.add(sb.toString());
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:20,代码来源:StreamingJsonParserTest.java

示例3: createReaderInput

import org.python.google.common.collect.Lists; //导入依赖的package包/类
private void createReaderInput()
{
  int cnt = 3;

  recordList = Lists.newArrayList();

  while (cnt > 0) {
    GenericRecord rec = new GenericData.Record(new Schema.Parser().parse(AVRO_SCHEMA));
    rec.put("orderId", cnt * 1L);
    rec.put("customerId", cnt * 2);
    rec.put("total", cnt * 1.5);
    rec.put("customerName", "*" + cnt + "*");
    cnt--;
    recordList.add(rec);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:AvroToPojoTest.java

示例4: testParquetReading

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void testParquetReading() throws Exception
{
  FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
  List<EventRecord> data = Lists.newArrayList();
  data.add(new EventRecord(1, "cust1", 12321L, true, 12.22f, 12.23));
  data.add(new EventRecord(2, "cust2", 12322L, true, 22.22f, 22.23));
  data.add(new EventRecord(3, "cust3", 12323L, true, 32.22f, 32.23));
  writeParquetFile(PARQUET_SCHEMA, new File(testMeta.dir, "data.parquet"), data);

  parquetFilePOJOReader.output.setSink(outputSink);
  parquetFilePOJOReader.setDirectory(testMeta.dir);
  parquetFilePOJOReader.setParquetSchema(PARQUET_SCHEMA);
  parquetFilePOJOReader.setup(testMeta.context);
  parquetFilePOJOReader.output.setup(testMeta.portContext);

  for (long wid = 0; wid < 2; wid++) {
    parquetFilePOJOReader.beginWindow(0);
    parquetFilePOJOReader.emitTuples();
    parquetFilePOJOReader.endWindow();
  }

  Assert.assertEquals("number tuples", 3, outputSink.collectedTuples.size());
  parquetFilePOJOReader.teardown();

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:27,代码来源:ParquetFilePOJOReaderTest.java

示例5: testParquetEmptyFile

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void testParquetEmptyFile() throws Exception
{
  FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
  List<EventRecord> data = Lists.newArrayList();
  writeParquetFile(PARQUET_SCHEMA, new File(testMeta.dir, "data.parquet"), data);

  parquetFilePOJOReader.output.setSink(outputSink);
  parquetFilePOJOReader.setDirectory(testMeta.dir);
  parquetFilePOJOReader.setParquetSchema(PARQUET_SCHEMA);
  parquetFilePOJOReader.setup(testMeta.context);
  testMeta.portContext.getAttributes().put(Context.PortContext.TUPLE_CLASS, EventRecordV2.class);
  parquetFilePOJOReader.output.setup(testMeta.portContext);

  for (long wid = 0; wid < 2; wid++) {
    parquetFilePOJOReader.beginWindow(0);
    parquetFilePOJOReader.emitTuples();
    parquetFilePOJOReader.endWindow();
  }

  Assert.assertEquals("number tuples", 0, outputSink.collectedTuples.size());
  parquetFilePOJOReader.teardown();

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:25,代码来源:ParquetFilePOJOReaderTest.java

示例6: testApplication

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void testApplication() throws IOException, Exception
{
  try {
    FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
    List<EventRecord> data = Lists.newArrayList();
    data.add(new EventRecord(1, "cust1", 12321L, true, 12.22f, 12.23));
    data.add(new EventRecord(2, "cust2", 12322L, true, 22.22f, 22.23));
    data.add(new EventRecord(3, "cust3", 12323L, true, 32.22f, 32.23));
    writeParquetFile(PARQUET_SCHEMA, new File(testMeta.dir, "data.parquet"), data);
    parquetFilePOJOReader.setDirectory(testMeta.dir);
    parquetFilePOJOReader.setParquetSchema(PARQUET_SCHEMA);
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    ParquetReaderApplication parquetReaderApplication = new ParquetReaderApplication();
    parquetReaderApplication.setParquetFilePOJOReader(parquetFilePOJOReader);
    lma.prepareDAG(parquetReaderApplication, conf);
    LocalMode.Controller lc = lma.getController();
    lc.run(10000);// runs for 10 seconds and quits
  } catch (ConstraintViolationException e) {
    Assert.fail("constraint violations: " + e.getConstraintViolations());
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:24,代码来源:ParquetFilePOJOReaderTest.java

示例7: whenValueIsNotThereItWillBeCreated

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void whenValueIsNotThereItWillBeCreated() throws Exception {
    Context context = mock(Context.class);
    ArrayList<Value> result = Lists.newArrayList(ValueFactory.create(1));
    when(scriptEvaluator.evalExpr(
            anyString(),
            anyMapOf(String.class, Value.class),
            anySetOf(SystemProperty.class),
            anySetOf(ScriptFunction.class))
    ).thenReturn(ValueFactory.create(result));
    Value loopCondition = ValueFactory.create(new ForLoopCondition(result));
    when(context.getLanguageVariable(LoopCondition.LOOP_CONDITION_KEY)).thenReturn(null);
    context.putLanguageVariable(LoopCondition.LOOP_CONDITION_KEY, loopCondition);
    when(context.getLanguageVariable(LoopCondition.LOOP_CONDITION_KEY)).thenReturn(loopCondition);
    loopsBinding.getOrCreateLoopCondition(createBasicForStatement(), context, EMPTY_SET, "node");
    verify(context).putLanguageVariable(LoopCondition.LOOP_CONDITION_KEY, loopCondition);
}
 
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:18,代码来源:LoopsBindingTest.java

示例8: whenValueIsThereItWillBeReturned

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void whenValueIsThereItWillBeReturned() throws Exception {
    Context context = mock(Context.class);
    ArrayList<Value> result = Lists.newArrayList(ValueFactory.create(1));
    when(scriptEvaluator.evalExpr(anyString(), anyMapOf(String.class, Value.class),
            eq(EMPTY_SET), eq(EMPTY_FUNCTION_SET)))
            .thenReturn(ValueFactory.create(result));
    Map<String, Value> langVars = new HashMap<>();
    ForLoopCondition forLoopCondition = new ForLoopCondition(result);
    langVars.put(LoopCondition.LOOP_CONDITION_KEY, ValueFactory.create(forLoopCondition));
    when(context.getLanguageVariable(LoopCondition.LOOP_CONDITION_KEY))
            .thenReturn(langVars.get(LoopCondition.LOOP_CONDITION_KEY));
    when(context.getImmutableViewOfLanguageVariables())
            .thenReturn(Collections.unmodifiableMap(langVars));
    loopsBinding.getOrCreateLoopCondition(createBasicForStatement(), context, EMPTY_SET, "node");
    Assert.assertEquals(true, context.getImmutableViewOfLanguageVariables()
            .containsKey(LoopCondition.LOOP_CONDITION_KEY));
    Assert.assertEquals(forLoopCondition, context.getImmutableViewOfLanguageVariables()
            .get(LoopCondition.LOOP_CONDITION_KEY).get());
}
 
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:21,代码来源:LoopsBindingTest.java

示例9: testOutputsRetainOrder

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test(timeout = DEFAULT_TIMEOUT)
public void testOutputsRetainOrder() {
    Map<String, Value> operationContext = prepareOperationContext();
    Map<String, Value> actionReturnValues = prepareActionReturnValues();
    List<Output> outputs = Lists.newArrayList(
        createExpressionOutput("output1", "1"),
        createExpressionOutput("output2", "2"),
        createExpressionOutput("output3", "3")
    );

    Map<String, Value> result = outputsBinding
        .bindOutputs(MapUtils.mergeMaps(operationContext, actionReturnValues), EMPTY_SET, outputs);

    List<String> actualInputNames = Lists.newArrayList(result.keySet());
    List<String> expectedInputNames = Lists.newArrayList("output1", "output2", "output3");

    Assert.assertEquals("Binding results are not as expected", expectedInputNames, actualInputNames);
}
 
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:19,代码来源:OutputsBindingTest.java

示例10: createAvroInput

import org.python.google.common.collect.Lists; //导入依赖的package包/类
private void createAvroInput(int cnt)
{
  recordList = Lists.newArrayList();

  while (cnt > 0) {
    GenericRecord rec = new GenericData.Record(new Schema.Parser().parse(AVRO_SCHEMA));
    rec.put("orderId", cnt * 1L);
    rec.put("customerId", cnt * 2);
    rec.put("total", cnt * 1.5);
    rec.put("customerName", "*" + cnt + "*");
    cnt--;
    recordList.add(rec);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:15,代码来源:AvroFileToPojoModuleTest.java

示例11: writeErrorFile

import org.python.google.common.collect.Lists; //导入依赖的package包/类
private void writeErrorFile(int cnt, File errorFile) throws IOException
{
  List<String> allLines = Lists.newArrayList();
  HashSet<String> lines = Sets.newHashSet();
  for (int line = 0; line < 5; line++) {
    lines.add("f0" + "l" + line);
  }

  allLines.addAll(lines);

  FileUtils.write(errorFile, StringUtils.join(lines, '\n'));

  FileUtils.moveFileToDirectory(new File(errorFile.getAbsolutePath()), new File(testMeta.dir), true);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:15,代码来源:AvroFileInputOperatorTest.java

示例12: testParquetReadingWithParquetToPojoMapping

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void testParquetReadingWithParquetToPojoMapping() throws Exception
{
  FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
  List<EventRecord> data = Lists.newArrayList();
  data.add(new EventRecord(1, "cust1", 12321L, true, 12.22f, 12.23));
  data.add(new EventRecord(2, "cust2", 12322L, true, 22.22f, 22.23));
  data.add(new EventRecord(3, "cust3", 12323L, true, 32.22f, 32.23));
  writeParquetFile(PARQUET_SCHEMA, new File(testMeta.dir, "data.parquet"), data);

  parquetFilePOJOReader.output.setSink(outputSink);
  parquetFilePOJOReader.setDirectory(testMeta.dir);
  parquetFilePOJOReader.setParquetSchema(PARQUET_SCHEMA);
  parquetFilePOJOReader.setParquetToPOJOFieldsMapping(
      "event_id:event_id_v2:INTEGER,org_id:org_id_v2:STRING,long_id:long_id_v2:LONG,css_file_loaded:css_file_loaded_v2:BOOLEAN,float_val:float_val_v2:FLOAT,double_val:double_val_v2:DOUBLE");
  parquetFilePOJOReader.setup(testMeta.context);
  testMeta.portContext.getAttributes().put(Context.PortContext.TUPLE_CLASS, EventRecordV2.class);
  parquetFilePOJOReader.output.setup(testMeta.portContext);

  for (long wid = 0; wid < 2; wid++) {
    parquetFilePOJOReader.beginWindow(0);
    parquetFilePOJOReader.emitTuples();
    parquetFilePOJOReader.endWindow();
  }

  Assert.assertEquals("number tuples", 3, outputSink.collectedTuples.size());
  parquetFilePOJOReader.teardown();

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:30,代码来源:ParquetFilePOJOReaderTest.java

示例13: testParquetIncorrectFormat

import org.python.google.common.collect.Lists; //导入依赖的package包/类
@Test
public void testParquetIncorrectFormat() throws Exception
{
  FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
  List<String> allLines = Lists.newArrayList();
  HashSet<String> lines = Sets.newHashSet();
  for (int line = 0; line < 5; line++) {
    lines.add("f0" + "l" + line);
  }
  allLines.addAll(lines);
  File testFile = new File(testMeta.dir, "file0");
  FileUtils.write(testFile, StringUtils.join(lines, '\n'));

  parquetFilePOJOReader.output.setSink(outputSink);
  parquetFilePOJOReader.setDirectory(testMeta.dir);
  parquetFilePOJOReader.setParquetSchema(PARQUET_SCHEMA);
  parquetFilePOJOReader.setParquetToPOJOFieldsMapping(
      "event_id:event_id_v2:INTEGER,org_id:org_id_v2:STRING,long_id:long_id_v2:LONG,css_file_loaded:css_file_loaded_v2:BOOLEAN,float_val:float_val_v2:FLOAT,double_val:double_val_v2:DOUBLE");
  parquetFilePOJOReader.setup(testMeta.context);
  testMeta.portContext.getAttributes().put(Context.PortContext.TUPLE_CLASS, EventRecordV2.class);
  parquetFilePOJOReader.output.setup(testMeta.portContext);

  for (long wid = 0; wid < 2; wid++) {
    parquetFilePOJOReader.beginWindow(0);
    parquetFilePOJOReader.emitTuples();
    parquetFilePOJOReader.endWindow();
  }

  Assert.assertEquals("number tuples", 0, outputSink.collectedTuples.size());
  parquetFilePOJOReader.teardown();

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:33,代码来源:ParquetFilePOJOReaderTest.java

示例14: generateTasksWithBlock

import org.python.google.common.collect.Lists; //导入依赖的package包/类
private Map<TaskId, InternalTask> generateTasksWithBlock() {
    Map<TaskId, InternalTask> tempTasks = Maps.newHashMap();
    InternalTask startTask = generateInternalTask(555L);
    startTask.setFlowBlock(FlowBlock.START);
    tempTasks.put(startTask.getId(), startTask);

    InternalTask internalTask2 = generateInternalTask(666L);
    tempTasks.put(internalTask2.getId(), internalTask2);
    internalTask2.addDependence(startTask);

    InternalTask internalTask3 = generateInternalTask(888L);
    tempTasks.put(internalTask3.getId(), internalTask3);
    internalTask3.addDependence(startTask);
    when(jobDescriptorImpl.getTaskChildren(startTask)).thenReturn(Lists.newArrayList(internalTask2, internalTask3));

    InternalTask endTask = generateInternalTask(999L);
    tempTasks.put(endTask.getId(), endTask);
    endTask.setFlowBlock(FlowBlock.END);
    when(jobDescriptorImpl.getTaskChildren(internalTask2)).thenReturn(Lists.newArrayList(endTask));
    when(jobDescriptorImpl.getTaskChildren(internalTask3)).thenReturn(Lists.newArrayList(endTask));

    endTask.addDependence(internalTask2);
    endTask.addDependence(internalTask3);

    InternalTask mergeTask = generateInternalTask(MERGE_TASK_ID);
    tempTasks.put(mergeTask.getId(), mergeTask);
    mergeTask.addDependence(endTask);

    InternalTask initiatorTask = generateInitiatorTask();
    startTask.addDependence(initiatorTask);

    tempTasks.put(initiatorTask.getId(), initiatorTask);

    return tempTasks;
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:36,代码来源:TerminateReplicateTaskHandlerTest.java

示例15: getPossibleResults

import org.python.google.common.collect.Lists; //导入依赖的package包/类
private List<String> getPossibleResults(Step step, List<String> refResults) {
    List<String> possibleResults;
    if (step.isParallelLoop()) {
        possibleResults = Lists.newArrayList(ScoreLangConstants.SUCCESS_RESULT);
        if (refResults.contains(ScoreLangConstants.FAILURE_RESULT)) {
            possibleResults.add(ScoreLangConstants.FAILURE_RESULT);
        }

    } else {
        possibleResults = refResults;
    }
    return possibleResults;
}
 
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:14,代码来源:CompileValidatorImpl.java


注:本文中的org.python.google.common.collect.Lists类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。