Пример #1
0
 @Test
 public void shouldPrintToStringAllResults() {
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   List<String> lines = StringUtil.splitLines(results.toString());
   assertThat(
       lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim
 }
Пример #2
0
 @Test
 public void shouldPrintToStringBuilderOnlyFirstLinesOfResults() {
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   StringBuilder sb = new StringBuilder();
   results.toString(typeSystem, sb, 1);
   List<String> lines = StringUtil.splitLines(sb.toString());
   assertThat(lines.size(), is(1 + 4)); // = delim + header + delim + (...lines...) + delim
 }
Пример #3
0
 @Test
 public void shouldPrintToStringBuilderAllResultsWhenMaxRowParameterIsLargerThanNumberOfTuples() {
   tuples.clear();
   results = new QueryResults(columns, statistics, tuples, context.getProblems(), null);
   StringBuilder sb = new StringBuilder();
   results.toString(typeSystem, sb, 3);
   List<String> lines = StringUtil.splitLines(sb.toString());
   assertThat(
       lines.size(), is(tuples.size() + 4)); // = delim + header + delim + (...lines...) + delim
 }
Пример #4
0
 protected Map<Name, Property> load(File propertiesFile, ExecutionContext context)
     throws RepositorySourceException {
   if (!propertiesFile.exists() || !propertiesFile.canRead()) return NO_PROPERTIES_MAP;
   try {
     String content = IoUtil.read(propertiesFile);
     ValueFactories factories = context.getValueFactories();
     PropertyFactory propFactory = context.getPropertyFactory();
     Map<Name, Property> result = new HashMap<Name, Property>();
     for (String line : StringUtil.splitLines(content)) {
       // Parse each line ...
       Property property = parse(line, factories, propFactory);
       if (property != null) {
         result.put(property.getName(), property);
       }
     }
     return result;
   } catch (IOException e) {
     throw new RepositorySourceException(sourceName, e);
   }
 }