Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always set isReplace when the replace ip is set. #1102

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
Loading