Dependency { public Dependency setScope( String scope ) { if ( this.scope.equals( scope ) || ( scope == null && this.scope.length() <= 0 ) ) { return this; } return new Dependency( artifact, scope, exclusions, optional ); } Dependency( Artifact artifact, String scope );  Dependency( Artifact artifact, String scope, boolean optional );  Dependency( Artifact artifact, String scope, boolean optional, Collection<Exclusion> exclusions ); private  Dependency( Artifact artifact, String scope, Set<Exclusion> exclusions, boolean optional ); Artifact getArtifact(); Dependency setArtifact( Artifact artifact ); String getScope(); Dependency setScope( String scope ); boolean isOptional(); Dependency setOptional( boolean optional ); Collection<Exclusion> getExclusions(); Dependency setExclusions( Collection<Exclusion> exclusions ); @Override String toString(); @Override boolean equals( Object obj ); @Override int hashCode();  }
@Test public void testSetScope() { Dependency d1 = new Dependency( new StubArtifact( "gid:aid:ver" ), "compile" ); Dependency d2 = d1.setScope( null ); assertNotSame( d2, d1 ); assertEquals( "", d2.getScope() ); Dependency d3 = d1.setScope( "test" ); assertNotSame( d3, d1 ); assertEquals( "test", d3.getScope() ); }