Java Code Examples for com.beust.jcommander.internal.Lists#newArrayList()
The following examples show how to use
com.beust.jcommander.internal.Lists#newArrayList() .
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: TestTransformCommandCluster.java From kite with Apache License 2.0 | 6 votes |
@Test public void testTransform() throws Exception { command.repoURI = repoUri; command.transform = "org.kitesdk.cli.example.ToUpperCase"; command.datasets = Lists.newArrayList(source, dest); int rc = command.run(); Assert.assertEquals("Should return success", 0, rc); DatasetRepository repo = DatasetRepositories.repositoryFor("repo:" + repoUri); Set<GenericRecord> records = DatasetTestUtilities.materialize( repo.<GenericRecord>load("default", dest)); Assert.assertEquals("Should contain copied records", 6, records.size()); for (GenericRecord record : records) { Assert.assertTrue("Username should be upper case", UPPER_CASE.matcher(record.get("username").toString()).matches()); } }
Example 2
Source File: TestTransformCommandCluster.java From kite with Apache License 2.0 | 6 votes |
@Test public void testCopyWithoutCompaction() throws Exception { command.repoURI = repoUri; command.noCompaction = true; command.datasets = Lists.newArrayList(source, dest); int rc = command.run(); Assert.assertEquals("Should return success", 0, rc); DatasetRepository repo = DatasetRepositories.repositoryFor("repo:" + repoUri); FileSystemDataset<GenericData.Record> ds = (FileSystemDataset<GenericData.Record>) repo.<GenericData.Record> load("default", dest); int size = DatasetTestUtilities.datasetSize(ds); Assert.assertEquals("Should contain copied records", 6, size); Assert.assertEquals("Should produce 1 files", 1, Iterators.size(ds.pathIterator())); verify(console).info("Added {} records to \"{}\"", 6l, dest); verifyNoMoreInteractions(console); }
Example 3
Source File: TestTransformCommandCluster.java From kite with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void testCopyWithNumWriters() throws Exception { Assume.assumeTrue(setLocalReducerMax(getConfiguration(), 3)); command.repoURI = repoUri; command.numWriters = 3; command.datasets = Lists.newArrayList(source, dest); int rc = command.run(); Assert.assertEquals("Should return success", 0, rc); DatasetRepository repo = DatasetRepositories.repositoryFor("repo:" + repoUri); FileSystemDataset<GenericData.Record> ds = (FileSystemDataset<GenericData.Record>) repo.<GenericData.Record> load("default", dest); int size = DatasetTestUtilities.datasetSize(ds); Assert.assertEquals("Should contain copied records", 6, size); Assert.assertEquals("Should produce 3 files", 3, Iterators.size(ds.pathIterator())); verify(console).info("Added {} records to \"{}\"", 6l, dest); verifyNoMoreInteractions(console); }
Example 4
Source File: TestCSVImportCommand.java From kite with Apache License 2.0 | 6 votes |
@Test public void testIncompatibleSchemaFieldType() throws Exception { BufferedWriter writer = Files.newWriter( new File("target/incompatible.csv"), CSVSchemaCommand.SCHEMA_CHARSET); writer.append("id,username,email\n"); writer.append("NaN,test,[email protected]\n"); // id will be String writer.close(); // This will fail because NaN isn't a valid long and the field is required command.targets = Lists.newArrayList("target/incompatible.csv", datasetName); int rc = command.run(); Assert.assertEquals(1, rc); verify(console).trace(contains("repo:file:target/data")); verifyNoMoreInteractions(console); }
Example 5
Source File: WxUtils.java From wish-pay with Apache License 2.0 | 6 votes |
public static String getSign(Map<String, Object> map, String key) { List<String> list = Lists.newArrayList(); for (Map.Entry<String, Object> entry : map.entrySet()) { if (entry.getValue() != "") { list.add(entry.getKey() + "=" + entry.getValue() + "&"); } } int size = list.size(); String[] arrayToSort = list.toArray(new String[size]); Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); StringBuilder sb = new StringBuilder(); for (int i = 0; i < size; i++) { sb.append(arrayToSort[i]); } String result = sb.toString(); result += "key=" + key; //Util.log("Sign Before MD5:" + result); result = md5(result).toUpperCase(); //Util.log("Sign Result:" + result); return result; }
Example 6
Source File: TestCreateColumnMappingCommand.java From kite with Apache License 2.0 | 6 votes |
@Test public void testVersionWithCounterTypes() throws Exception { // longs and ints are mapped command.partitions = Lists.newArrayList( "email:key", "version:version", "username:u", "created_at:u"); command.run(); ColumnMapping mapping = new ColumnMapping.Builder() .version("version") .key("email") .column("username", "u", "username") .column("created_at", "u", "created_at") .build(); verify(console).info(mapping.toString(true)); verifyNoMoreInteractions(console); }
Example 7
Source File: TestInputFormatImportCommandCluster.java From kite with Apache License 2.0 | 6 votes |
@Test public void testMRImportWithTransform() throws Exception { Path sample = new Path(temp.newFile("sample.sequence").toString()) .makeQualified(getDFS().getUri(), new Path("/")); writeSequenceFile(getDFS(), sample); // HDFS sequence file // Reusing records is okay when running in MR command.inFormatClass = SequenceFileInputFormat.class.getName(); command.targets = Lists.newArrayList(sample.toString(), datasetUri); command.noCompaction = true; // no need to run reducers command.transform = TransformMeasurement.class.getName(); int rc = command.run(); Assert.assertEquals("Should return success", 0, rc); verify(console).info("Added {} records to \"{}\"", 3L, datasetUri); verifyNoMoreInteractions(console); Set<Measurement> datasetContent = materialize( Datasets.load(datasetUri, Measurement.class)); Set<Measurement> expected = Sets.newHashSet(Iterables.transform( measurements, new TransformMeasurement())); Assert.assertEquals(expected, datasetContent); }
Example 8
Source File: TestCopyCommandClusterNewField.java From kite with Apache License 2.0 | 6 votes |
@Override public Schema getEvolvedSchema(Schema original) { List<Schema.Field> fields = Lists.newArrayList(); fields.add(new Schema.Field("new", Schema.createUnion(ImmutableList.of( Schema.create(Schema.Type.NULL), Schema.create(Schema.Type.STRING))), "New field", NullNode.getInstance())); for (Schema.Field field : original.getFields()) { fields.add(new Schema.Field(field.name(), field.schema(), field.doc(), field.defaultValue())); } Schema evolved = Schema.createRecord(original.getName(), original.getDoc(), original.getNamespace(), false); evolved.setFields(fields); return evolved; }
Example 9
Source File: WxUtils.java From wish-pay with Apache License 2.0 | 6 votes |
/** * 签名算法 * * @param o 要参与签名的数据对象 * @return 签名 * @throws IllegalAccessException */ public static String getSign(Object o, String key) throws IllegalAccessException { List<String> list = Lists.newArrayList(); Class cls = o.getClass(); Field[] fields = cls.getDeclaredFields(); for (Field f : fields) { f.setAccessible(true); if (f.get(o) != null && f.get(o) != "") { list.add(f.getName() + "=" + f.get(o) + "&"); } } int size = list.size(); String[] arrayToSort = list.toArray(new String[size]); Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER); StringBuilder sb = new StringBuilder(); for (int i = 0; i < size; i++) { sb.append(arrayToSort[i]); } String result = sb.toString(); result += "key=" + key; //log.log("Sign Before MD5:" + result); result = md5(result).toUpperCase(); //Util.log("Sign Result:" + result); return result; }
Example 10
Source File: TestCreatePartitionStrategyCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testNested() throws Exception { command.partitions = Lists.newArrayList("address.line1:copy"); command.run(); PartitionStrategy strategy = new PartitionStrategy.Builder() .identity("address.line1") .build(); verify(console).info(strategy.toString(true)); verifyNoMoreInteractions(console); }
Example 11
Source File: TestCreateColumnMappingCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testCounterWithQualifier() throws Exception { command.partitions = Lists.newArrayList( "email:key", "username:u", "created_at:u:ts"); command.run(); ColumnMapping mapping = new ColumnMapping.Builder() .key("email") .column("username", "u", "username") .counter("created_at", "u", "ts") .build(); verify(console).info(mapping.toString(true)); verifyNoMoreInteractions(console); }
Example 12
Source File: ClientServerTest.java From opc-ua-stack with Apache License 2.0 | 5 votes |
private void connectAndTest(Variant input, UaTcpStackClient client) throws InterruptedException, java.util.concurrent.ExecutionException { client.connect().get(); List<TestStackRequest> requests = Lists.newArrayList(); List<CompletableFuture<? extends UaResponseMessage>> futures = Lists.newArrayList(); for (int i = 0; i < 1000; i++) { RequestHeader header = new RequestHeader( NodeId.NULL_VALUE, DateTime.now(), uint(i), uint(0), null, uint(60000), null); requests.add(new TestStackRequest(header, uint(i), i, input)); CompletableFuture<TestStackResponse> future = new CompletableFuture<>(); future.thenAccept((response) -> assertEquals(response.getOutput(), input)); futures.add(future); } client.sendRequests(requests, futures); CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()])).get(); client.disconnect().get(); Thread.sleep(100); }
Example 13
Source File: TestCopyCommandLocal.java From kite with Apache License 2.0 | 5 votes |
@Test public void testBasicCopy() throws Exception { command.repoURI = "file:target/data"; command.datasets = Lists.newArrayList(source, dest); int rc = command.run(); Assert.assertEquals("Should return success", 0, rc); DatasetRepository repo = DatasetRepositories.repositoryFor("repo:file:target/data"); int size = DatasetTestUtilities.datasetSize(repo.load("default", source)); Assert.assertEquals("Should contain copied records", 2, size); }
Example 14
Source File: TestCreateColumnMappingCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testBasic() throws Exception { command.partitions = Lists.newArrayList( "email:key", "username:u", "created_at:u"); command.run(); ColumnMapping mapping = new ColumnMapping.Builder() .key("email") .column("username", "u", "username") .counter("created_at", "u", "created_at") .build(); verify(console).info(mapping.toString(true)); verifyNoMoreInteractions(console); }
Example 15
Source File: TestCreateColumnMappingCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testQualifier() throws Exception { command.partitions = Lists.newArrayList( "email:key", "username:u:n"); command.run(); ColumnMapping mapping = new ColumnMapping.Builder() .key("email") .column("username", "u", "n") .build(); verify(console).info(mapping.toString(true)); verifyNoMoreInteractions(console); }
Example 16
Source File: TestCreateColumnMappingCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testUnknownVersionSourceField() { command.partitions = Lists.newArrayList("grizzly:version"); TestHelpers.assertThrows("Should reject unknown version field \"grizzly\"", ValidationException.class, new Callable() { @Override public Object call() throws Exception { command.run(); return null; } }); }
Example 17
Source File: TestCreatePartitionStrategyCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testBasic() throws Exception { command.partitions = Lists.newArrayList( "username:hash[16]", "username:copy"); command.run(); PartitionStrategy strategy = new PartitionStrategy.Builder() .hash("username", 16) .identity("username") .build(); verify(console).info(strategy.toString(true)); verifyNoMoreInteractions(console); }
Example 18
Source File: GithubFacade.java From sputnik with Apache License 2.0 | 5 votes |
@NotNull @Override public List<ReviewFile> listFiles() { Pull pull = getPull(); List<ReviewFile> files = Lists.newArrayList(); try { for (JsonObject o : pull.files()) { files.add(new ReviewFile(o.getString("filename"))); } } catch (IOException ex) { log.error("Error fetching files for pull request", ex); } return files; }
Example 19
Source File: TestCSVImportCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testMissingSamplePath() throws Exception { command.targets = Lists.newArrayList("missing.csv", datasetName); TestHelpers.assertThrows("Should complain about missing CSV data path", IllegalArgumentException.class, new Callable() { @Override public Object call() throws Exception { command.run(); return null; } }); verifyNoMoreInteractions(console); }
Example 20
Source File: TestCreateColumnMappingCommand.java From kite with Apache License 2.0 | 5 votes |
@Test public void testVersion() throws Exception { command.partitions = Lists.newArrayList( "email:key", "username:u:n", "version:version"); command.run(); ColumnMapping mapping = new ColumnMapping.Builder() .version("version") .key("email") .column("username", "u", "n") .build(); verify(console).info(mapping.toString(true)); verifyNoMoreInteractions(console); }