-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e738dd
commit 36c0433
Showing
18 changed files
with
283 additions
and
133 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
commons/src/test/java/io/github/dengliming/redismodule/common/ArgsUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2022 dengliming. | ||
* | ||
* 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 | ||
* | ||
* http://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 io.github.dengliming.redismodule.common; | ||
|
||
import io.github.dengliming.redismodule.common.util.ArgsUtil; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ArgsUtilTest { | ||
|
||
@Test | ||
public void testAppend() { | ||
assertThat(ArgsUtil.append("key1", "a", "b", "c")).containsExactly("key1", "a", "b", "c"); | ||
Map<String, Object> params = new HashMap<>(); | ||
params.put("k1", "v1"); | ||
params.put("k2", "v2"); | ||
Object[] result = ArgsUtil.append("key2", params); | ||
assertThat(result).hasSize(5); | ||
assertThat(result).contains("key2"); | ||
assertThat(result).contains("k1", "v1"); | ||
assertThat(result).contains("k2", "v2"); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
commons/src/test/java/io/github/dengliming/redismodule/common/RAssertTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2022 dengliming. | ||
* | ||
* 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 | ||
* | ||
* http://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 io.github.dengliming.redismodule.common; | ||
|
||
import io.github.dengliming.redismodule.common.util.RAssert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.HashMap; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class RAssertTest { | ||
|
||
@Test | ||
public void test() { | ||
assertThrows(IllegalArgumentException.class, () -> RAssert.notNull(null, "test not null"), | ||
"test not null"); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> RAssert.notEmpty((CharSequence) null, "test CharSequence not empty"), | ||
"test CharSequence not empty"); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> RAssert.notEmpty(new Object[]{}, "test Object[] not empty"), | ||
"test Object[] not empty"); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> RAssert.notEmpty(new int[]{}, "test int[] not empty"), | ||
"test int[] not empty"); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> RAssert.notEmpty(new double[]{}, "test double[] not empty"), | ||
"test double[] not empty"); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> RAssert.isTrue(false, "test boolean is false"), | ||
"test boolean is false"); | ||
|
||
assertThrows(IllegalArgumentException.class, () -> RAssert.notEmpty(new HashMap<>(), "test HashMap not empty"), | ||
"test HashMap not empty"); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
commons/src/test/java/io/github/dengliming/redismodule/common/TestSettingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2022 dengliming. | ||
* | ||
* 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 | ||
* | ||
* http://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 io.github.dengliming.redismodule.common; | ||
|
||
import io.github.dengliming.redismodule.common.util.TestSettings; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class TestSettingsTest { | ||
|
||
@Test | ||
public void test() { | ||
assertThat(TestSettings.password()).isEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.