From 2bc782ee9c2a6bec4a8abc840538268566661b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=99=93=E5=8F=8C=20Li=20Xiao=20Shuang?= <644968328@qq.com> Date: Mon, 17 May 2021 09:42:10 +0800 Subject: [PATCH] add unit test for ServiceChangeEvent (#5714) --- .../push/v1/ServiceChangeEventTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 naming/src/test/java/com/alibaba/nacos/naming/push/v1/ServiceChangeEventTest.java diff --git a/naming/src/test/java/com/alibaba/nacos/naming/push/v1/ServiceChangeEventTest.java b/naming/src/test/java/com/alibaba/nacos/naming/push/v1/ServiceChangeEventTest.java new file mode 100644 index 00000000000..8e0d78ce969 --- /dev/null +++ b/naming/src/test/java/com/alibaba/nacos/naming/push/v1/ServiceChangeEventTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 1999-2020 Alibaba Group Holding Ltd. + * + * 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 com.alibaba.nacos.naming.push.v1; + +import com.alibaba.nacos.naming.core.Service; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class ServiceChangeEventTest { + + @Mock + private Service service; + + @Mock + private Object object; + + @Test + public void testGetService() { + ServiceChangeEvent serviceChangeEvent = new ServiceChangeEvent(object, service); + Service service = serviceChangeEvent.getService(); + + Assert.assertNotNull(service); + Assert.assertEquals(service, service); + } +} \ No newline at end of file