@Test(expectedExceptions = IllegalStateException.class) public void shouldFailOnMultiPopulates() throws Exception { final DatasetManifest manifest = new DatasetManifest("dataset", "file.csv", asList( new DatasetManifest.Part("FULL", "col1", asList("attr1", "attr2"), true, null) )); manifest.setMapping("col", "attr2"); }
public void setMapping(final String columnName, final String populates) { notNull(columnName, "columnName"); notNull(populates, "populates"); for (Part part : parts) { if (part.getPopulates() == null || part.getPopulates().size() != 1) { throw new IllegalStateException("Only parts with exactly one populates are supported " + part.getPopulates()); } final String field = part.getPopulates().iterator().next(); if (populates.equals(field)) { part.setColumnName(columnName); return; } } throw new IllegalArgumentException("Dataset manifest parts doesn't contain populate value " + populates); }
DatasetManifest { public void setMapping(final String columnName, final String populates) { notNull(columnName, "columnName"); notNull(populates, "populates"); for (Part part : parts) { if (part.getPopulates() == null || part.getPopulates().size() != 1) { throw new IllegalStateException("Only parts with exactly one populates are supported " + part.getPopulates()); } final String field = part.getPopulates().iterator().next(); if (populates.equals(field)) { part.setColumnName(columnName); return; } } throw new IllegalArgumentException("Dataset manifest parts doesn't contain populate value " + populates); } }
DatasetManifest { public void setMapping(final String columnName, final String populates) { notNull(columnName, "columnName"); notNull(populates, "populates"); for (Part part : parts) { if (part.getPopulates() == null || part.getPopulates().size() != 1) { throw new IllegalStateException("Only parts with exactly one populates are supported " + part.getPopulates()); } final String field = part.getPopulates().iterator().next(); if (populates.equals(field)) { part.setColumnName(columnName); return; } } throw new IllegalArgumentException("Dataset manifest parts doesn't contain populate value " + populates); } DatasetManifest(String dataSet);  DatasetManifest(final String dataSet, final InputStream source); @JsonCreator  DatasetManifest(@JsonProperty("dataSet") String dataSet, @JsonProperty("file") String file,
                           @JsonProperty("parts") List<Part> parts); }
DatasetManifest { public void setMapping(final String columnName, final String populates) { notNull(columnName, "columnName"); notNull(populates, "populates"); for (Part part : parts) { if (part.getPopulates() == null || part.getPopulates().size() != 1) { throw new IllegalStateException("Only parts with exactly one populates are supported " + part.getPopulates()); } final String field = part.getPopulates().iterator().next(); if (populates.equals(field)) { part.setColumnName(columnName); return; } } throw new IllegalArgumentException("Dataset manifest parts doesn't contain populate value " + populates); } DatasetManifest(String dataSet);  DatasetManifest(final String dataSet, final InputStream source); @JsonCreator  DatasetManifest(@JsonProperty("dataSet") String dataSet, @JsonProperty("file") String file,
                           @JsonProperty("parts") List<Part> parts); String getDataSet(); List<Part> getParts(); void setParts(List<Part> parts); String getFile(); void setFile(String file); void setUploadMode(final UploadMode uploadMode); void setMapping(final String columnName, final String populates); @JsonIgnore InputStream getSource(); @JsonIgnore void setSource(final InputStream source); @Override String toString(); }
DatasetManifest { public void setMapping(final String columnName, final String populates) { notNull(columnName, "columnName"); notNull(populates, "populates"); for (Part part : parts) { if (part.getPopulates() == null || part.getPopulates().size() != 1) { throw new IllegalStateException("Only parts with exactly one populates are supported " + part.getPopulates()); } final String field = part.getPopulates().iterator().next(); if (populates.equals(field)) { part.setColumnName(columnName); return; } } throw new IllegalArgumentException("Dataset manifest parts doesn't contain populate value " + populates); } DatasetManifest(String dataSet);  DatasetManifest(final String dataSet, final InputStream source); @JsonCreator  DatasetManifest(@JsonProperty("dataSet") String dataSet, @JsonProperty("file") String file,
                           @JsonProperty("parts") List<Part> parts); String getDataSet(); List<Part> getParts(); void setParts(List<Part> parts); String getFile(); void setFile(String file); void setUploadMode(final UploadMode uploadMode); void setMapping(final String columnName, final String populates); @JsonIgnore InputStream getSource(); @JsonIgnore void setSource(final InputStream source); @Override String toString(); static final String URI; }