summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DmaapClientFactoryTest.java
blob: b27c5b07a6bb6894bff2bd342aa8714ca6c3ce89 (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package org.openecomp.sdc.be.components.distribution.engine;

import java.io.File;
import java.security.GeneralSecurityException;
import java.util.Properties;

import org.junit.Test;
import org.openecomp.sdc.be.config.DmaapConsumerConfiguration;
import org.openecomp.sdc.be.config.DmaapConsumerConfiguration.Credential;

import com.att.nsa.mr.client.MRConsumer;

import mockit.Deencapsulation;

public class DmaapClientFactoryTest {

	private DmaapClientFactory createTestSubject() {
		return new DmaapClientFactory();
	}

	@Test
	public void testCreate() throws Exception {
		DmaapClientFactory testSubject;
		DmaapConsumerConfiguration parameters = new DmaapConsumerConfiguration();
		MRConsumer result;
		String filePath = "src/test/resources/config/mock.txt";

		Credential credential = new Credential();
		credential.setPassword("hmXYcznAljMSisdy8zgcag==");
		credential.setUsername("mock");
		parameters.setCredential(credential);
		parameters.setLatitude(new Double(32452));
		parameters.setLongitude(new Double(543534));
		parameters.setVersion("mock");
		parameters.setServiceName("mock");
		parameters.setServiceName("mock");
		parameters.setEnvironment("mock");
		parameters.setPartner("mock");
		parameters.setRouteOffer("mock");
		parameters.setProtocol("mock");
		parameters.setContenttype("mock");
		parameters.setHosts("mock");
		parameters.setTopic("mock");
		parameters.setConsumerGroup("mock");
		parameters.setConsumerId("mock");
		parameters.setTimeoutMs(42354);
		parameters.setLimit(43534);
		parameters.setDme2TraceOn(true);
		parameters.setAftEnvironment("mock");
		parameters.setAftDme2ConnectionTimeoutMs(234324);
		parameters.setAftDme2RoundtripTimeoutMs(435345);
		parameters.setAftDme2ReadTimeoutMs(5645);
		parameters.setDme2preferredRouterFilePath(filePath);

		// default test
		testSubject = createTestSubject();
		result = testSubject.create(parameters);
		File file = new File(filePath);
		file.delete();
		
	}

	@Test
	public void testBuildProperties() throws Exception {
		DmaapClientFactory testSubject;
		DmaapConsumerConfiguration parameters = new DmaapConsumerConfiguration();
		Properties result;
		String filePath = "src/test/resources/config/mock.txt";

		Credential credential = new Credential();
		credential.setPassword("hmXYcznAljMSisdy8zgcag==");
		credential.setUsername("mock");
		parameters.setCredential(credential);
		parameters.setLatitude(new Double(32452));
		parameters.setLongitude(new Double(543534));
		parameters.setVersion("mock");
		parameters.setServiceName("mock");
		parameters.setServiceName("mock");
		parameters.setEnvironment("mock");
		parameters.setPartner("mock");
		parameters.setRouteOffer("mock");
		parameters.setProtocol("mock");
		parameters.setContenttype("mock");
		parameters.setHosts("mock");
		parameters.setTopic("mock");
		parameters.setConsumerGroup("mock");
		parameters.setConsumerId("mock");
		parameters.setTimeoutMs(42354);
		parameters.setLimit(43534);
		parameters.setDme2TraceOn(true);
		parameters.setAftEnvironment("mock");
		parameters.setAftDme2ConnectionTimeoutMs(234324);
		parameters.setAftDme2RoundtripTimeoutMs(435345);
		parameters.setAftDme2ReadTimeoutMs(5645);
		parameters.setDme2preferredRouterFilePath(filePath);

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "buildProperties", parameters);

		File file = new File(filePath);
		file.delete();
	}

	@Test(expected = GeneralSecurityException.class)
	public void testBuildProperties_2() throws Exception {
		DmaapClientFactory testSubject;
		DmaapConsumerConfiguration parameters = new DmaapConsumerConfiguration();
		Properties result;
		String filePath = "src/test/resources/config/mock.txt";

		Credential credential = new Credential();
		credential.setPassword("mock");
		parameters.setCredential(credential);

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "buildProperties", parameters);
	}

	@Test
	public void testEnsureFileExists() throws Exception {
		DmaapClientFactory testSubject;
		String filePath = "src/test/resources/config/mock.txt";

		// default test
		testSubject = createTestSubject();
		Deencapsulation.invoke(testSubject, "ensureFileExists", new Object[] { filePath });
		Deencapsulation.invoke(testSubject, "ensureFileExists", filePath);
		File file = new File(filePath);
		file.delete();
	}
}