Skip to content

Commit

Permalink
Merge pull request #164 from cinovo/cleanup
Browse files Browse the repository at this point in the history
code cleanup
  • Loading branch information
YukiInu authored Jul 24, 2024
2 parents 05aca20 + 225ebf7 commit 1238c67
Show file tree
Hide file tree
Showing 32 changed files with 104 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import de.taimos.daemon.log4j.Log4jDaemonProperties;
import de.taimos.daemon.log4j.Log4jLoggingConfigurer;

@Deprecated
/**
@deprecated use Log4jLoggingConfigurer with JSON layout
* @deprecated use Log4jLoggingConfigurer with JSON layout
*/
@Deprecated
public class StructuredLogConfigurer {

public static void setup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@ExtendWith(SpringDaemonExtension.class)
@RunnerConfiguration(config = DvalinTestRunnerConfig.class, loggingConfigurer = Log4jLoggingConfigurer.class, svc = "AdditionalConfigTest")
@AdditionalRunnerConfiguration(config = {AdditionalTestConfig.class})
public class AdditionalConfigTest {
class AdditionalConfigTest {

@Value("${jwtauth.issuer}")
private String jwtIssuer;
Expand All @@ -27,7 +27,7 @@ public class AdditionalConfigTest {
* Test if the property from {@link AdditionalTestConfig} was set up.
*/
@Test
public void testAdditionalConfiguration() {
void testAdditionalConfiguration() {
Assertions.assertEquals(AdditionalTestConfig.TEST_VALUE, this.jwtIssuer, "The propery 'jwtauth.issuer' was not equals to the value of AdditionalTestConfig.TEST_VALUE");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @author fzwirn
*/
@ExtendWith(SpringDaemonExtension.class)
public class ExtensionTest extends AbstractTest {
class ExtensionTest extends AbstractTest {

@Test
void testDemo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
class SpringLockTest {

@Test
public void startContext() throws Exception {
void startContext() throws Exception {
TestAdapter adapter = new TestAdapter("good");
adapter.doStart();
}

@Test
public void testCtx() throws Exception {
void testCtx() throws Exception {
TestAdapter adapter = new TestAdapter("good");
adapter.doStart();
Assertions.assertNotNull(adapter.getContext());
Expand All @@ -41,7 +41,7 @@ public void testCtx() throws Exception {
}

@Test
public void testStopBad() {
void testStopBad() {
TestAdapter adapter = new TestAdapter("bad");
try {
adapter.doStart();
Expand Down Expand Up @@ -73,7 +73,7 @@ public void testDoubleStart() throws Exception {
}

@Test
public void testDoubleStop() throws Exception {
void testDoubleStop() throws Exception {
TestAdapter adapter = new TestAdapter("good");
adapter.doStart();
Assertions.assertNotNull(adapter.getContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class EnumMarshallerTest {
class EnumMarshallerTest {

@Test
public void marshall() throws Exception {
void marshall() throws Exception {
EnumMarshaller m = new EnumMarshaller();
Assertions.assertEquals(TestEnum.EnumValue1.toString(), m.marshall(TestEnum.EnumValue1));
Assertions.assertEquals(TestEnum.ENUMVALUE2.toString(), m.marshall(TestEnum.ENUMVALUE2));
}

@Test
public void marshallNull() throws Exception {
void marshallNull() throws Exception {
EnumMarshaller m = new EnumMarshaller();
Assertions.assertNull(m.marshall(null));
}

@Test
public void unmarshall() throws Exception {
void unmarshall() throws Exception {
EnumMarshaller m = new EnumMarshaller();
Assertions.assertEquals(TestEnum.EnumValue1, m.unmarshall(TestEnum.class, TestEnum.EnumValue1.toString()));
Assertions.assertEquals(TestEnum.ENUMVALUE2, m.unmarshall(TestEnum.class, TestEnum.ENUMVALUE2.toString()));
}

@Test
public void unmarshallNull() throws Exception {
void unmarshallNull() throws Exception {
EnumMarshaller m = new EnumMarshaller();
Assertions.assertNull(m.unmarshall(TestEnum.class, null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ public final void onMessage(final Message message) throws Exception {
if (this.throwExceptionOnTimeout) {
throw new Exception("Response skipped because runtime " + runtime + " ms was greater than timeout " + method.getTimeoutInMs() + " ms for " + method.getMethod().getName() + "(" + icoClass.getSimpleName() + ")" + " with " + InterconnectContext.getContext());
}
this.getLogger().warn("Response skipped because runtime " + runtime + " ms was greater than timeout " + method.getTimeoutInMs() + " ms for " + method.getMethod().getName() + "(" + icoClass.getSimpleName() + ")" + " with " + InterconnectContext.getContext());
this.getLogger().warn("Response skipped because runtime {} ms was greater than timeout {} ms for {}({}) with {}", runtime, method.getTimeoutInMs(), method.getMethod().getName(), icoClass.getSimpleName(), InterconnectContext.getContext());
return;
} else if (runtime > (method.getTimeoutInMs() / 2L)) {
this.getLogger().info("Slow response because runtime " + runtime + " ms for " + method.getMethod().getName() + "(" + icoClass.getSimpleName() + ")" + " with " + InterconnectContext.getContext());
this.getLogger().info("Slow response because runtime {} ms for {}({}) with {}", runtime, method.getMethod().getName(), icoClass.getSimpleName(), InterconnectContext.getContext());
}
} catch (final DaemonError e) {
this.getLogger().debug("DaemonError for " + method.getMethod().getName() + "(" + icoClass.getSimpleName() + ")" + " with " + InterconnectContext.getContext(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro
}

@Override
@Deprecated
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {
InjectionMetadata metadata = this.buildResourceMetadata(bean.getClass());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
* @author thoeger
*/
@Component
@SuppressWarnings("serial")
public class InterconnectBeanPostProcessor
implements InstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected StringMemberDef createStringMemberDef(String name, String comment) {

protected EnumMemberDef createEnumMemberDef(Class<? extends Enum<?>> clazz, String name, String comment) {
EnumMemberDef emd = new EnumMemberDef();
emd.setComment(name);
emd.setComment(comment);
emd.setName(name);
emd.setClazz(clazz.getSimpleName());
emd.setPkgName(clazz.getPackage().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
public class GenericConverter {

/**
* @param <Destination> the destination
* @param <Origin> the origin
* @param <DESTINATION> the destination
* @param <ORIGIN> the origin
* @param origin object to be copied from
* @param destinationClass destination for reference
* @return new object copied from origin to destination
*/
@SuppressWarnings("unchecked")
public static <Destination, Origin> Destination convert(Origin origin, Class<Destination> destinationClass) {
public static <DESTINATION, ORIGIN> DESTINATION convert(ORIGIN origin, Class<DESTINATION> destinationClass) {
Class targetClazz = destinationClass;
boolean usesBuilder = false;

Expand All @@ -59,10 +59,10 @@ public static <Destination, Origin> Destination convert(Origin origin, Class<Des
if(usesBuilder) {
return GenericConverter.invokeBuilderMethod(result);
}
return (Destination) result;
return (DESTINATION) result;
}

private static <Destination, Origin> Destination copy(Origin origin, Destination target) {
private static <DESTINATION, ORIGIN> DESTINATION copy(ORIGIN origin, DESTINATION target) {
HashMap<Field, Field> map = GenericConverter.prepareFieldMapping(origin, target);
for(Entry<Field, Field> entry : map.entrySet()) {
//we only want fields which are present in both objects
Expand All @@ -83,7 +83,7 @@ private static <Destination, Origin> Destination copy(Origin origin, Destination
private static Object getFieldValue(Object object, Field field) throws IllegalAccessException {
try {
String capitalizedFieldName = field.getName();
if((capitalizedFieldName != null) && (!capitalizedFieldName.isEmpty())) {
if(!capitalizedFieldName.isEmpty()) {
capitalizedFieldName = capitalizedFieldName.substring(0, 1).toUpperCase(Locale.ENGLISH) + capitalizedFieldName.substring(1);
}
Method getter = object.getClass().getMethod("get" + capitalizedFieldName);
Expand All @@ -97,10 +97,10 @@ private static Object getFieldValue(Object object, Field field) throws IllegalAc
}

@SuppressWarnings("unchecked")
private static <Destination> Destination invokeBuilderMethod(Object result) {
private static <DESTINATION> DESTINATION invokeBuilderMethod(Object result) {
try {
Method method = result.getClass().getMethod("build");
return (Destination) method.invoke(result);
return (DESTINATION) method.invoke(result);
} catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException("No build method found");
}
Expand All @@ -114,7 +114,7 @@ private static Object createNewClassInstance(Class destinationClass) {
}
}

private static <Destination, Origin> HashMap<Field, Field> prepareFieldMapping(Origin origin, Destination destination) {
private static <DESTINATION, ORIGIN> HashMap<Field, Field> prepareFieldMapping(ORIGIN origin, DESTINATION destination) {
HashMap<String, Field> createFieldMap = GenericConverter.createFieldMap(origin);
HashMap<String, Field> createFieldMap2 = GenericConverter.createFieldMap(destination);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* 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.
Expand Down Expand Up @@ -126,7 +126,7 @@ public List<E> getElements() {
@SuppressWarnings("unchecked")
@Override
public IVOQueryResultIVO_v1Builder<E> createBuilder() {
IVOQueryResultIVO_v1Builder<E> builder = new IVOQueryResultIVO_v1Builder<E>();
IVOQueryResultIVO_v1Builder<E> builder = new IVOQueryResultIVO_v1Builder<>();
builder.withElements(this.elements);
builder.withPossibleResults(this.possibleResults);
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* 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.
Expand Down Expand Up @@ -127,7 +127,7 @@ public List<E> getAuditingElements() {
@SuppressWarnings("unchecked")
@Override
public IVOWithAuditingResultIVO_v1Builder<E> createBuilder() {
IVOWithAuditingResultIVO_v1Builder<E> builder = new IVOWithAuditingResultIVO_v1Builder<E>();
IVOWithAuditingResultIVO_v1Builder<E> builder = new IVOWithAuditingResultIVO_v1Builder<>();
builder.withAuditingElements(this.auditingElements);
builder.withElement(this.element);
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public Context(final Class<? extends IVO> aRequestClass, final UUID anUUID, fina
/**
* @param aRequestClass Request class
* @param anUUID Universally unique identifier of the request
* @deprecated use other constructor
*/
@Deprecated
public Context(final Class<? extends IVO> aRequestClass, final UUID anUUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@

import de.taimos.dvalin.interconnect.model.ivo.daemon.DaemonErrorIVO;

@SuppressWarnings("javadoc")
public final class InterconnectListTest {
final class InterconnectListTest {

@Test
public void testSerialization() throws Exception {
void testSerialization() throws Exception {
final List<DaemonErrorIVO> elements = new ArrayList<>();
elements.add(new DaemonErrorIVO.DaemonErrorIVOBuilder().build());
elements.add(new DaemonErrorIVO.DaemonErrorIVOBuilder().build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;

@SuppressWarnings("javadoc")
final class FutureImplTest {

@Test
Expand Down Expand Up @@ -140,7 +139,7 @@ void testGetAfterCancel() {
}

@Test
public void testSetValueAfterCancel() {
void testSetValueAfterCancel() {
final FutureImpl<Integer> f = new FutureImpl<>();
Assertions.assertTrue(f.cancel(true));
Assertions.assertTrue(f.isCancelled());
Expand All @@ -149,7 +148,7 @@ public void testSetValueAfterCancel() {
}

@Test
public void testSetExceptionAfterCancel() {
void testSetExceptionAfterCancel() {
final FutureImpl<Integer> f = new FutureImpl<>();
Assertions.assertTrue(f.cancel(true));
Assertions.assertTrue(f.isCancelled());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import de.taimos.dvalin.interconnect.model.service.ADaemonErrorNumber;
import de.taimos.dvalin.interconnect.model.service.DaemonErrorNumber;

@SuppressWarnings("javadoc")
public final class ADaemonErrorNumberTest {
final class ADaemonErrorNumberTest {

private static final class TestError extends ADaemonErrorNumber {

Expand All @@ -42,23 +41,23 @@ public TestError(final int aNumber, final String aDaemon) {


@Test
public void testEquals1() {
void testEquals1() {
Assertions.assertEquals(new TestError(1, "test"), new TestError(1, "test"));
}

@Test
public void testEquals2() {
void testEquals2() {
final DaemonErrorNumber den = new TestError(1, "test");
Assertions.assertEquals(den, den);
}

@Test
public void testNotEquals1() {
void testNotEquals1() {
Assertions.assertNotEquals(new TestError(1, "test"), new TestError(2, "test"));
}

@Test
public void testNotEquals2() {
void testNotEquals2() {
Assertions.assertNotEquals(new TestError(1, "test1"), new TestError(1, "test2"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

@SuppressWarnings({"javadoc", "unused"})
@SuppressWarnings({"unused"})
public class DaemonScannerTest {

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
import de.taimos.dvalin.interconnect.model.InterconnectObject;


@SuppressWarnings("javadoc")
public final class DaemonErrorIVOTest {
final class DaemonErrorIVOTest {

@Test
public void testICO() throws Exception {
void testICO() throws Exception {
final DaemonErrorIVO in = new DaemonErrorIVO.DaemonErrorIVOBuilder().build();
final String json = InterconnectMapper.toJson(in);
final InterconnectObject out = InterconnectMapper.fromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
import de.taimos.dvalin.interconnect.model.InterconnectObject;


@SuppressWarnings("javadoc")
public final class PingIVOTest {
final class PingIVOTest {

@Test
public void testICO() throws Exception {
void testICO() throws Exception {
final PingIVO in = new PingIVO.PingIVOBuilder().build();
final String json = InterconnectMapper.toJson(in);
final InterconnectObject out = InterconnectMapper.fromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

@SuppressWarnings("javadoc")
public final class PongIVOTest {
final class PongIVOTest {

@Test
public void testICO() throws Exception {
void testICO() throws Exception {
final PongIVO in = new PongIVO.PongIVOBuilder().build();
final String json = InterconnectMapper.toJson(in);
final InterconnectObject out = InterconnectMapper.fromJson(json);
Expand Down
Loading

0 comments on commit 1238c67

Please sign in to comment.