Skip to content

Commit

Permalink
Always set isReplace when the replace ip is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattl-netflix committed Sep 3, 2024
1 parent a782b79 commit 98d8895
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void setReplacedIp(String replacedIp) {
throw new IllegalArgumentException(
replacedIp + " is neither empty nor a valid IpV4 address");
}
if (!StringUtils.isEmpty(replacedIp)) this.isReplace = true;
this.isReplace = !StringUtils.isEmpty(replacedIp);
}

private static boolean isInstanceDummy(PriamInstance instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,20 @@ public void testIsReplace_validReplaceIp() throws Exception {
identity.setReplacedIp("1.2.3.4");
Truth.assertThat(identity.isReplace()).isTrue();
}

@Test
public void testIsReplace_nullThenValid() throws Exception {
InstanceIdentity identity = createInstanceIdentity("az1", "fakeinstancex");
identity.setReplacedIp(null);
identity.setReplacedIp("1.2.3.4");
Truth.assertThat(identity.isReplace()).isTrue();
}

@Test
public void testIsReplace_validThenNull() throws Exception {
InstanceIdentity identity = createInstanceIdentity("az1", "fakeinstancex");
identity.setReplacedIp("1.2.3.4");
identity.setReplacedIp(null);
Truth.assertThat(identity.isReplace()).isFalse();
}
}

0 comments on commit 98d8895

Please sign in to comment.