Ref { public static Ref createRemoteRef(String repositoryName, String name) { CheckUtilities.checkStringArgument(name, "name"); Ref cn = new Ref(); cn.refType = RefType.REMOTE; cn.name = name; if (null != repositoryName && repositoryName.length() > 0) { cn.repositoryName = repositoryName; } return cn; }  static Ref createBranchRef(String name); static Ref createHeadRef(int headOffset); static Ref createRemoteRef(String repositoryName, String name); static Ref createSha1Ref(String name); static Ref createTagRef(String name); Ref.RefType getRefType(); int getHeadOffset(); String getName(); String getRepositoryName(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final Ref HEAD; static final Ref HEAD_1; }
@Test public void testCreateRemoteRef() { assertCreateRemoteRefThrowsNPE(null, null, "000001: A String argument was not specified but is required. { variableName=[name] }"); assertCreateRemoteRefThrowsIllegalArgException(null, "", "000001: A String argument was not specified but is required. { variableName=[name] }"); Ref ref = Ref.createRemoteRef(null, "newFeatureDev"); Ref ref2 = Ref.createRemoteRef(null, "newFeatureDev"); assertEquals("Expected RefType of REMOTE.", ref.getRefType(), Ref.RefType.REMOTE); assertEquals(ref.getHeadOffset(), -1); assertEquals(ref.getName(), "newFeatureDev"); assertEquals(ref.getRepositoryName(), null); assertEquals(ref.toString(), "newFeatureDev"); assertEquals(ref, ref2); assertEquals(ref.hashCode(), ref2.hashCode()); ref = Ref.createRemoteRef(null, "review0"); assertTrue(!ref.equals(ref2)); ref2 = Ref.createRemoteRef("", "review0"); assertEquals("Expected RefType of REMOTE.", ref.getRefType(), Ref.RefType.REMOTE); assertEquals(ref.getHeadOffset(), -1); assertEquals(ref.getName(), "review0"); assertEquals(ref.getRepositoryName(), null); assertEquals(ref.toString(), "review0"); assertEquals(ref, ref2); assertEquals(ref.hashCode(), ref2.hashCode()); ref = Ref.createRemoteRef("", "nextReview"); assertTrue(!ref.equals(ref2)); ref2 = Ref.createRemoteRef("", "nextReview"); assertEquals("Expected RefType of REMOTE.", ref.getRefType(), Ref.RefType.REMOTE); assertEquals(ref.getHeadOffset(), -1); assertEquals(ref.getName(), "nextReview"); assertEquals(ref.getRepositoryName(), null); assertEquals(ref.toString(), "nextReview"); assertEquals(ref, ref2); assertEquals(ref.hashCode(), ref2.hashCode()); ref = Ref.createRemoteRef("origin", "stable"); assertTrue(!ref.equals(ref2)); ref2 = Ref.createRemoteRef("origin", "stable"); assertEquals("Expected RefType of REMOTE.", ref.getRefType(), Ref.RefType.REMOTE); assertEquals(ref.getHeadOffset(), -1); assertEquals(ref.getName(), "stable"); assertEquals(ref.getRepositoryName(), "origin"); assertEquals(ref.toString(), "origin/stable"); assertEquals(ref, ref2); assertEquals(ref.hashCode(), ref2.hashCode()); ref = Ref.createRemoteRef("jhlRepo", "stable"); assertTrue(!ref.equals(ref2)); ref2 = Ref.createRemoteRef("jhlRepo", "stable"); assertEquals("Expected RefType of REMOTE.", ref.getRefType(), Ref.RefType.REMOTE); assertEquals(ref.getHeadOffset(), -1); assertEquals(ref.getName(), "stable"); assertEquals(ref.getRepositoryName(), "jhlRepo"); assertEquals(ref.toString(), "jhlRepo/stable"); assertEquals(ref, ref2); assertEquals(ref.hashCode(), ref2.hashCode()); }