AbstractNamed extends AbstractCloneable implements Named { @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void setName(String name) { if (name == null) throw new NullPointerException("Name can't be null"); Matcher invalidMatcher = INVALID_NAME.matcher(name); if (invalidMatcher.find()) throw new IllegalArgumentException("Name invalid in position " + invalidMatcher.start() + ": '" + name + "'"); if (this instanceof Child) { Child child = (Child) this; WorkflowBean parent = child.getParent(); if (parent != null) { child.setParent(null); this.name = name; child.setParent(parent); } } this.name = name; } AbstractNamed();  AbstractNamed(String name); @Override int compareTo(Object o); @Override boolean equals(Object obj); @Override String getName(); @SuppressWarnings({ "rawtypes" }) @Override int hashCode(); @Override @SuppressWarnings({ "unchecked", "rawtypes" }) void setName(String name); @Override String toString(); Collection<Annotation> getAnnotations(); URI getURI(); URI getRelativeURI(WorkflowBean relativeTo);  }
@Test(expected=IllegalArgumentException.class) public void nameWithNewline() throws Exception { Processor p = new Processor(); p.setName("new\nline"); }
@Test(expected=IllegalArgumentException.class) public void nameWithControlChar() throws Exception { Processor p = new Processor(); p.setName("no\bell"); }
@Test(expected=IllegalArgumentException.class) public void nameWithColon() throws Exception { Processor p = new Processor(); p.setName("not:url"); }
@Test(expected=IllegalArgumentException.class) public void nameWithSlash() throws Exception { Processor p = new Processor(); p.setName("no/slash"); }
@Test public void nameWithSpace() throws Exception { Processor p = new Processor(); p.setName("space allowed"); }
@Test public void setName() throws Exception { Workflow wf = new Workflow(); Processor p = new Processor(); p.setName("fish"); p.setName("soup"); p.setParent(wf); }
@Test public void setNameWithParent() throws Exception { Workflow wf = new Workflow(); Processor p = new Processor(); p.setName("fish"); p.setParent(wf); assertTrue(wf.getProcessors().contains(p)); assertTrue(wf.getProcessors().containsName("fish")); assertFalse(wf.getProcessors().containsName("soup")); p.setName("soup"); assertFalse(wf.getProcessors().containsName("fish")); assertTrue(wf.getProcessors().containsName("soup")); }
@Test public void replaceOnRename() throws Exception { Workflow wf = new Workflow(); Processor fish = new Processor(wf, "fish"); @SuppressWarnings("unused") Processor soup = new Processor(wf, "soup"); assertEquals(2, wf.getProcessors().size()); assertEquals(new HashSet(Arrays.asList("fish", "soup")), wf .getProcessors().getNames()); fish.setName("soup"); assertEquals(new HashSet(Arrays.asList("soup")), wf .getProcessors().getNames()); assertEquals(1, wf.getProcessors().size()); assertEquals(fish, wf.getProcessors().iterator().next()); assertEquals(fish, wf.getProcessors().getByName("soup")); assertNull(wf.getProcessors().getByName("fish")); }
@Test(expected=NullPointerException.class) public void nameNull() throws Exception { Processor p = new Processor(); p.setName(null); }
@Test(expected=IllegalArgumentException.class) public void nameEmpty() throws Exception { Processor p = new Processor(); p.setName(""); }