From 12b6e60b03fd4cee4933b9e22856d14e510d246f Mon Sep 17 00:00:00 2001 From: annippolito Date: Fri, 26 May 2023 08:47:02 +0200 Subject: [PATCH] change method signatures in LogMessage tests #1331 --- .../design/AbstractSubjectCenterTest.java | 23 ++++++++++++++++--- .../toolkit/logtracing/LogMessageTest.java | 16 ++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/infra/common/src/test/java/cn/hippo4j/common/extension/design/AbstractSubjectCenterTest.java b/infra/common/src/test/java/cn/hippo4j/common/extension/design/AbstractSubjectCenterTest.java index 44c31294..74bf2eac 100644 --- a/infra/common/src/test/java/cn/hippo4j/common/extension/design/AbstractSubjectCenterTest.java +++ b/infra/common/src/test/java/cn/hippo4j/common/extension/design/AbstractSubjectCenterTest.java @@ -1,3 +1,20 @@ +/* + * 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 cn.hippo4j.common.extension.design; import lombok.Getter; @@ -13,8 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class AbstractSubjectCenterTest { - - private Map> OBSERVERS_MAP ; + private Map> OBSERVERS_MAP; private SubjectNotifyListener subjectNotifyListener; @@ -130,13 +146,14 @@ public class AbstractSubjectCenterTest { @Getter private static final class NotifyMessage { + private final AtomicInteger count = new AtomicInteger(0); } /** * Subject Response Listener */ - private static final class SubjectNotifyListener implements Observer{ + private static final class SubjectNotifyListener implements Observer { @Override public void accept(ObserverMessage observerMessage) { diff --git a/infra/common/src/test/java/cn/hippo4j/common/toolkit/logtracing/LogMessageTest.java b/infra/common/src/test/java/cn/hippo4j/common/toolkit/logtracing/LogMessageTest.java index bf531a24..3d486bcf 100644 --- a/infra/common/src/test/java/cn/hippo4j/common/toolkit/logtracing/LogMessageTest.java +++ b/infra/common/src/test/java/cn/hippo4j/common/toolkit/logtracing/LogMessageTest.java @@ -39,25 +39,25 @@ class LogMessageTest { } @Test - void getInstance_shouldReturnANewLogMessageInstance() { + void testGetInstanceShouldReturnANewLogMessageInstance() { final LogMessage newInstance = LogMessage.getInstance(); assertNotNull(newInstance); assertNotSame(logMessage, newInstance); } @Test - void getInstance_shouldHaveAnEmptyMessage() { + void testToStringShouldHaveAnEmptyMessage() { assertEquals(Strings.EMPTY, logMessage.toString()); } @Test - void setMsg_shouldSetAnewMessageInLogMessage() { + void testSetMsgShouldSetAnewMessageInLogMessage() { logMessage.setMsg(MESSAGE); assertEquals(MESSAGE, logMessage.toString()); } @Test - void msg_shouldContainsMessageAndThrowableMessage() { + void testMsgShouldContainsMessageAndThrowableMessage() { final String message = logMessage.msg(MESSAGE, new Throwable(THROWABLE_MESSAGE)); assertNotNull(message); assertTrue(message.contains(MESSAGE)); @@ -65,20 +65,20 @@ class LogMessageTest { } @Test - void toString_shouldPrintKeyAndValueWhenSet() { + void testKvShouldPutKeyAndValue() { logMessage.kv("key", "value"); assertEquals("key=value", logMessage.toString()); } @Test - void toString_shouldPrintAllKeyAndValuePairs() { + void testKvShouldPutAllKeyAndValuePairs() { logMessage.kv("key1", "value1"); logMessage.kv("key2", "value2"); assertEquals("key1=value1||key2=value2", logMessage.toString()); } @Test - void toString_shouldPrintMessageAndAllKeyAndValuePairs() { + void testToStringShouldPrintMessageAndAllKeyAndValuePairs() { logMessage.setMsg(MESSAGE); logMessage.kv("key1", "value1"); logMessage.kv("key2", "value2"); @@ -86,7 +86,7 @@ class LogMessageTest { } @Test - void kv2String_shouldPrintMessageAndAllKeyAndValuePairs() { + void testKv2StringShouldPrintMessageAndAllKeyAndValuePairs() { String result = logMessage.kv2String("key", "value"); assertEquals("key=value", result); }