Last active
January 18, 2016 12:17
-
-
Save prongs/96d6d26dc57f12b3d66a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final String XML_LICENSE_HEADER = "<!--\n" + | |
"\n" + | |
" Licensed to the Apache Software Foundation (ASF) under one\n" + | |
" or more contributor license agreements. See the NOTICE file\n" + | |
" distributed with this work for additional information\n" + | |
" regarding copyright ownership. The ASF licenses this file\n" + | |
" to you under the Apache License, Version 2.0 (the\n" + | |
" \"License\"); you may not use this file except in compliance\n" + | |
" with the License. You may obtain a copy of the License at\n" + | |
"\n" + | |
" http://www.apache.org/licenses/LICENSE-2.0\n" + | |
"\n" + | |
" Unless required by applicable law or agreed to in writing,\n" + | |
" software distributed under the License is distributed on an\n" + | |
" \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" + | |
" KIND, either express or implied. See the License for the\n" + | |
" specific language governing permissions and limitations\n" + | |
" under the License.\n" + | |
"\n" + | |
"-->\n"; | |
public static final String YAML_HEADER = "# Licensed to the Apache Software Foundation (ASF) under one\n" + | |
"# or more contributor license agreements. See the NOTICE file\n" + | |
"# distributed with this work for additional information\n" + | |
"# regarding copyright ownership. The ASF licenses this file\n" + | |
"# to you under the Apache License, Version 2.0 (the\n" + | |
"# \"License\"); you may not use this file except in compliance\n" + | |
"# with the License. You may obtain a copy of the License at\n" + | |
"#\n" + | |
"# http://www.apache.org/licenses/LICENSE-2.0\n" + | |
"#\n" + | |
"# Unless required by applicable law or agreed to in writing, software\n" + | |
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n" + | |
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" + | |
"# See the License for the specific language governing permissions and\n" + | |
"# limitations under the License.\n"; | |
Map<String, String> map = new HashMap<>(); | |
map.put("key1", "value1"); | |
map.put("key2", "value2"); | |
LensConf conf = new LensConf(); | |
conf.addProperties(map); | |
QueryHandle handle = new QueryHandle(UUID.randomUUID()); | |
QueryPrepareHandle pHandle = new QueryPrepareHandle(UUID.randomUUID()); | |
QueryStatus status = new QueryStatus(10.0, 11, QueryStatus.Status.RUNNING, | |
"query running", false, "progress message", "error message", | |
LensErrorTO.composedOf(9999, "error message", "random stack trace")); | |
QueryCostTO cost = new QueryCostTO(1000L, 10000.0, QueryCostType.HIGH); | |
List<ToYAMLString> objects = Lists.newArrayList( | |
handle, new QueryHandleWithResultSet(handle), conf, new DateTime(new Date()), status, pHandle, cost, | |
new LensPreparedQuery(new QueryPrepareHandle(UUID.randomUUID()), "cube select blah", new Date(), | |
"user", "selected-driver", "select blah from driver table", conf), | |
new LensQuery(handle, "cube select blah blah", "user", Priority.HIGH, true, | |
"selected-driver", "select blah from driver table", status, "/path/to/result", | |
UUID.randomUUID().toString(), conf, currentTimeMillis(), currentTimeMillis(), currentTimeMillis(), | |
currentTimeMillis(), currentTimeMillis(), currentTimeMillis(), "query name"), | |
new QueryPlan(Lists.newArrayList("table1", "table2"), false, "MapReduce", "scanning mode 1", pHandle, | |
"plan is to\nrun this\nbig query one \nby one", cost) | |
); | |
for (ToYAMLString object : objects) { | |
BufferedWriter xmlWriter = new BufferedWriter(new FileWriter(new File("src/test/resources/toString/" + object | |
.getClass().getSimpleName() + ".xml"))); | |
BufferedWriter toStringWriter = new BufferedWriter(new FileWriter(new File("src/test/resources/toString/" + | |
object.getClass().getSimpleName() + ".yaml"))); | |
xmlWriter.write(XML_LICENSE_HEADER); | |
xmlWriter.write(ToXMLString.toString(object)); | |
xmlWriter.close(); | |
toStringWriter.write(YAML_HEADER); | |
toStringWriter.write(object.toString()); | |
toStringWriter.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment