/
ServiceEventModuleConfigurationTest.java
96 lines (84 loc) · 5.8 KB
/
ServiceEventModuleConfigurationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*******************************************************************************
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.commons.event;
import org.eclipse.kapua.commons.jpa.EntityManagerFactory;
import org.eclipse.kapua.qa.markers.junit.JUnitTests;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@Category(JUnitTests.class)
public class ServiceEventModuleConfigurationTest extends Assert {
EntityManagerFactory entityManagerFactory;
ServiceEventClientConfiguration[] serviceEventClientConfiguration = new ServiceEventClientConfiguration[]
{ new ServiceEventClientConfiguration("address", "subscriberName", null),
new ServiceEventClientConfiguration("address2", "subscriberName2", null) };
@Test
public void serviceEventModuleConfigurationRegularTest() {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration("internalAddress", entityManagerFactory, serviceEventClientConfiguration);
assertEquals("Expected and actual values are not equals!", "internalAddress", moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertArrayEquals("Arrays are not equals!", serviceEventClientConfiguration, moduleConfiguration.getServiceEventClientConfigurations());
}
@Test
public void serviceEventModuleConfigurationNullAddressTest() {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration(null, entityManagerFactory, serviceEventClientConfiguration);
assertNull("Null expected!", moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertArrayEquals(serviceEventClientConfiguration, moduleConfiguration.getServiceEventClientConfigurations());
}
@Test
public void serviceEventModuleConfigurationNullEntityTest() {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration("internalAddress", null, serviceEventClientConfiguration);
assertEquals("Expected and actual values are not equals!", "internalAddress", moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertArrayEquals("Arrays are not equals!", serviceEventClientConfiguration, moduleConfiguration.getServiceEventClientConfigurations());
}
@Test
public void constructorClientConfigNullTest() {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration("internalAddress", entityManagerFactory, null);
assertEquals("Expected and actual values are not equals!", "internalAddress", moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertNull("Null expected!", moduleConfiguration.getServiceEventClientConfigurations());
}
@Test
public void serviceEventModuleConfigurationNullEntityAndAddressTest() {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration(null, null, serviceEventClientConfiguration);
assertNull("Null expected!", moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertArrayEquals("Arrays are not equals!", serviceEventClientConfiguration, moduleConfiguration.getServiceEventClientConfigurations());
}
@Test
public void constructorEntityAndClientConfigNullTest() {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration("internalAddress", null, null);
assertEquals("Expected and actual values are not equals!", "internalAddress", moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertNull("Null expected!", moduleConfiguration.getServiceEventClientConfigurations());
}
@Test
public void serviceEventModuleConfigurationAllNullTest() {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration(null, null, null);
assertNull("Null expected!", moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertNull("Null expected!", moduleConfiguration.getServiceEventClientConfigurations());
}
@Test
public void constructorAddressCharCheckTest() {
String[] permittedValues = {"", "!#$%&'()=?⁄@‹›€°·‚,.-;:_Èˇ¿<>«‘”’ÉØ∏{}|ÆæÒuF8FFÔÓÌÏÎÅ«»Ç◊ш¯Èˇ", "regularNaming", "regular Naming", "49", "regularNaming49", "NAMING", "246465494135646120009090049684646496468456468496846464968496844"};
for (String value : permittedValues) {
ServiceEventModuleConfiguration moduleConfiguration = new ServiceEventModuleConfiguration(value, entityManagerFactory, serviceEventClientConfiguration);
assertEquals("Expected and actual values are not equals!", value, moduleConfiguration.getInternalAddress());
assertNull("Null expected!", moduleConfiguration.getEntityManagerFactory());
assertArrayEquals("Arrays are not equals!", serviceEventClientConfiguration, moduleConfiguration.getServiceEventClientConfigurations());
}
}
}