This is an automated email from the ASF dual-hosted git repository.
xiaoyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 5149a149b [type:test] add test cases for shenyu-admin.model (#4540)
(#4550)
5149a149b is described below
commit 5149a149b3a1b583b0fc36c1ea4b9b33c828b1e5
Author: Zhang Yuxuan <[email protected]>
AuthorDate: Wed Apr 12 14:36:17 2023 +0800
[type:test] add test cases for shenyu-admin.model (#4540) (#4550)
* [type:test] add test for shenyu-admin.model (#4540)
* [type:test] add test for shenyu-admin.model (#4540)
---------
Co-authored-by: moremind <[email protected]>
---
.../shenyu/admin/model/bean/DocParameterTest.java | 70 ++++++++++++++++++++++
.../admin/model/bean/UpstreamInstanceTest.java | 66 ++++++++++++++++++++
2 files changed, 136 insertions(+)
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/bean/DocParameterTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/bean/DocParameterTest.java
new file mode 100644
index 000000000..fdc2563fb
--- /dev/null
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/bean/DocParameterTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shenyu.admin.model.bean;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * test cast for {@link DocParameter}.
+ */
+public final class DocParameterTest {
+
+ private DocParameter docParameter;
+
+ @BeforeEach
+ public void setUp() {
+ docParameter = new DocParameter();
+ docParameter.setDescription("shenyuDescription");
+ docParameter.setExample("shenyuExample");
+ docParameter.setId(0);
+ docParameter.setMaxLength("shenyuMaxLength");
+ docParameter.setModule("shenyuSetModule");
+ docParameter.setName("shenyuName");
+ docParameter.setRequired(true);
+ docParameter.setType("shenyuType");
+ docParameter.setXExample("shenyuXExample");
+ docParameter.setRefs(Collections.singletonList(docParameter));
+ }
+
+ @Test
+ public void testEquals() {
+ assertEquals("shenyuDescription", docParameter.getDescription());
+ assertEquals(0, docParameter.getId().intValue());
+ assertEquals("shenyuMaxLength", docParameter.getMaxLength());
+ assertEquals("shenyuSetModule", docParameter.getModule());
+ assertEquals("shenyuName", docParameter.getName());
+ assertTrue(docParameter.isRequired());
+ assertEquals("shenyuType", docParameter.getType());
+ assertEquals("shenyuXExample", docParameter.getXExample());
+ assertEquals(Collections.singletonList(docParameter),
docParameter.getRefs());
+ }
+
+ @Test
+ public void testGetExample() {
+ assertEquals("shenyuExample", docParameter.getExample());
+ docParameter.setExample("");
+ final String example = docParameter.getExample();
+ assertEquals("shenyuXExample", docParameter.getExample());
+ }
+}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/bean/UpstreamInstanceTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/bean/UpstreamInstanceTest.java
new file mode 100644
index 000000000..1aaee8415
--- /dev/null
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/bean/UpstreamInstanceTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shenyu.admin.model.bean;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+/**
+ * test cast for {@link UpstreamInstance}.
+ */
+public class UpstreamInstanceTest {
+
+ private UpstreamInstance upstreamInstance;
+
+ @BeforeEach
+ public void setup() {
+ upstreamInstance = new UpstreamInstance();
+ upstreamInstance.setContextPath("ShenyuContextPath");
+ upstreamInstance.setIp("0.0.0.0");
+ upstreamInstance.setPort(9195);
+ upstreamInstance.setStartupTime(123L);
+ upstreamInstance.setEnabled(true);
+ upstreamInstance.setHealthy(true);
+ }
+
+ @Test
+ public void testEquals() {
+ assertEquals("ShenyuContextPath", upstreamInstance.getContextPath());
+ assertEquals("0.0.0.0", upstreamInstance.getIp());
+ assertEquals(9195, upstreamInstance.getPort());
+ assertEquals(123L, upstreamInstance.getStartupTime());
+ assertTrue(upstreamInstance.isEnabled());
+ assertTrue(upstreamInstance.isHealthy());
+ }
+
+ @Test
+ public void testGetClusterName() {
+ assertEquals(upstreamInstance.getClusterName(), "henyuContextPath");
+ upstreamInstance.setContextPath("");
+ assertNull(upstreamInstance.getClusterName());
+ }
+
+ @Test
+ public void testHashCode() {
+ assertEquals(236671917, upstreamInstance.hashCode());
+ }
+}