Thing extends Resource implements ThingId, UserId, CategoryId, LanguageId { public void merge(Submission submission) { if (submission.getUrl() != null && !this.getUrl().equals(submission.getUrl())) { throw new IllegalArgumentException("Thing URL '" + getUrl() + "' cannot be changed to '" + submission.getUrl() + "'"); } this.setCategory(submission.getCategory()); this.setTitle(submission.getTitle()); this.setDescription(submission.getDescription()); this.setLanguage(submission.getLanguage()); this.setTags(submission.getTags()); if (submission.isHidden() != null) { this.setHidden(submission.isHidden()); } } Thing(FlattrObject data); static ThingId withId(final String id); @Override String getThingId(); String getResource(); String getLink(); Date getCreated(); int getClicks(); String getUrl(); String getTitle(); void setTitle(String title); String getImage(); @Override String getUserId(); User getUser(); @Override String getCategoryId(); void setCategory(CategoryId category); String getDescription(); void setDescription(String description); List<String> getTags(); void setTags(List<String> tags); void addTag(String tag); @Override String getLanguageId(); void setLanguage(LanguageId language); boolean isHidden(); void setHidden(boolean hidden); boolean isFlattred(); boolean isSubscribed(); Date getLastFlattr(); Date getUpdated(); void merge(Submission submission); FlattrObject toUpdate(); String getQrPdfUrl(); @Override boolean equals(Object obj); @Override int hashCode();  }
@SuppressWarnings("unchecked") @Test public void testMerge() throws FlattrException, IOException { Thing thing = ModelGenerator.createThing(); Submission sub = new Submission(); sub.setTitle("example title"); sub.setDescription("example description"); sub.setCategory(Category.withId("text")); sub.setLanguage(Language.withId("es_ES")); sub.addTag("foo"); sub.addTag("bar"); sub.setHidden(true); thing.merge(sub); assertThat(thing, allOf( hasProperty("title", is("example title")), hasProperty("description", is("example description")), hasProperty("categoryId", is("text")), hasProperty("languageId", is("es_ES")), hasProperty("tags", contains("foo", "bar")), hasProperty("hidden", is(true)), hasProperty("url", is("http: )); thing = ModelGenerator.createThing(); sub.setUrl(thing.getUrl()); thing.merge(sub); assertThat(thing, hasProperty("url", is("http: thing = ModelGenerator.createThing(); sub.setUrl("http: try { thing.merge(sub); fail("could use different url"); } catch (IllegalArgumentException ex) { } }