Skip to content

Commit

Permalink
Fix 1661 (#1662)
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 authored Jun 10, 2024
1 parent c86e5f6 commit be3ed08
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void setNamespace(String namespace) {
}

public String getNamespace(String defaultValue) {
if (!StringUtils.hasText(defaultValue)) {
if (!StringUtils.hasText(namespace)) {
return defaultValue;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2013-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.cloud.kubernetes.commons.leader;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* @author wind57
*/
class LeaderPropertiesTests {

@Test
void getNamespaceNull() {
LeaderProperties leaderProperties = new LeaderProperties();
String namespace = leaderProperties.getNamespace("a");
Assertions.assertEquals("a", namespace);
}

@Test
void getNamespaceEmpty() {
LeaderProperties leaderProperties = new LeaderProperties();
leaderProperties.setNamespace("");
String namespace = leaderProperties.getNamespace("a");
Assertions.assertEquals("a", namespace);
}

@Test
void getNamespacePresent() {
LeaderProperties leaderProperties = new LeaderProperties();
leaderProperties.setNamespace("c");
String namespace = leaderProperties.getNamespace("a");
Assertions.assertEquals("c", namespace);
}

}

0 comments on commit be3ed08

Please sign in to comment.