aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java/org/openecomp/sdc/be/model/cache/ComponentCacheTest.java
blob: 419666b686c036122e87fcc86c071f142a5047a1 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
package org.openecomp.sdc.be.model.cache;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;

import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.resources.data.ComponentCacheData;

import fj.data.Either;
import mockit.Deencapsulation;

@Ignore
public class ComponentCacheTest {

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

	@Test
	public void testInit() throws Exception {
		ComponentCache testSubject;

		// default test
		testSubject = createTestSubject();
		testSubject.init();
	}

	@Test
	public void testIsEnabled() throws Exception {
		ComponentCache testSubject;
		boolean result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.isEnabled();
	}

	@Test
	public void testSetEnabled() throws Exception {
		ComponentCache testSubject;
		boolean enabled = false;

		// default test
		testSubject = createTestSubject();
		testSubject.setEnabled(enabled);
	}

	@Test
	public void testGetComponent() throws Exception {
		ComponentCache testSubject;
		String componentUid = "";
		Long lastModificationTime = null;
		Function<Component, Component> filterFieldsFunc = null;
		Either<Component, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponent(componentUid, lastModificationTime, filterFieldsFunc);
	}

	@Test
	public void testGetAllComponentIdTimeAndType() throws Exception {
		ComponentCache testSubject;
		Either<List<ComponentCacheData>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getAllComponentIdTimeAndType();
	}

	@Test
	public void testGetComponentsForCatalog() throws Exception {
		ComponentCache testSubject;
		Set<String> components = null;
		ComponentTypeEnum componentTypeEnum = null;
		Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponentsForCatalog(components, componentTypeEnum);
	}

	@Test
	public void testUpdateCatalogInMemoryCacheWithCertified() throws Exception {
		ComponentCache testSubject;
		List<Component> foundComponents = null;
		ComponentTypeEnum componentTypeEnum = null;

		// default test
		testSubject = createTestSubject();
		Deencapsulation.invoke(testSubject, "updateCatalogInMemoryCacheWithCertified", List.class,
				ComponentTypeEnum.class);
	}

	@Test
	public void testGetDataFromInMemoryCache() throws Exception {
		ComponentCache testSubject;
		Set<String> components = null;
		ComponentTypeEnum componentTypeEnum = null;
		List<Component> result;

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "getDataFromInMemoryCache", Set.class, ComponentTypeEnum.class);
	}

	@Test
	public void testGetComponents() throws Exception {
		ComponentCache testSubject;
		Set<String> components = null;
		Function<List<Component>, List<Component>> filterFieldsFunc = null;
		Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponents(components, filterFieldsFunc);
	}

	@Test
	public void testGetComponentsForLeftPanel() throws Exception {
		ComponentCache testSubject;
		ComponentTypeEnum componentTypeEnum = null;
		String internalComponentType = "";
		Set<String> filteredResources = null;
		Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponentsForLeftPanel(componentTypeEnum, internalComponentType, filteredResources);
	}

	@Test
	public void testFilterForLeftPanel() throws Exception {
		ComponentCache testSubject;
		List<Component> components = null;
		List<Component> result;

		// test 1
		testSubject = createTestSubject();
		components = null;
		result = Deencapsulation.invoke(testSubject, "filterForLeftPanel", List.class);
		Assert.assertEquals(null, result);
	}

	@Test
	public void testFilterForCatalog() throws Exception {
		ComponentCache testSubject;
		List<Component> components = null;
		List<Component> result;

		// test 1
		testSubject = createTestSubject();
		components = null;
		result = Deencapsulation.invoke(testSubject, "filterForCatalog", List.class);
		Assert.assertEquals(null, result);
	}

	@Test
	public void testFilterFieldsForLeftPanel() throws Exception {
		ComponentCache testSubject;
		Component component = null;
		Component result;

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "filterFieldsForLeftPanel", new Object[] { Component.class });
	}

	@Test
	public void testFilterFieldsForCatalog() throws Exception {
		ComponentCache testSubject;
		Component component = null;
		Component result;

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "filterFieldsForCatalog", new Object[] { Component.class });
	}

	@Test
	public void testCopyFieldsForLeftPanel() throws Exception {
		ComponentCache testSubject;
		Component component = null;
		Component filteredComponent = null;

		// default test
		testSubject = createTestSubject();
		Deencapsulation.invoke(testSubject, "copyFieldsForLeftPanel",
				new Object[] { Component.class, Component.class });
	}

	@Test
	public void testCopyFieldsForCatalog() throws Exception {
		ComponentCache testSubject;
		Component component = null;
		Component filteredComponent = null;

		// default test
		testSubject = createTestSubject();
		Deencapsulation.invoke(testSubject, "copyFieldsForCatalog", new Object[] { Component.class, Component.class });
	}

	@Test
	public void testGetComponentsFull() throws Exception {
		ComponentCache testSubject;
		Set<String> filteredResources = null;
		Either<ImmutableTriple<List<Component>, List<Component>, Set<String>>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "getComponentsFull", Set.class);
	}

	@Test
	public void testConvertComponentCacheToComponent() throws Exception {
		ComponentCache testSubject;
		ComponentCacheData componentCacheData = null;
		Either<? extends Component, Boolean> result;

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "convertComponentCacheToComponent",
				new Object[] { ComponentCacheData.class });
	}

	@Test
	public void testDeserializeComponent() throws Exception {
		ComponentCache testSubject;
		ComponentCacheData componentCacheData = null;
		byte[] dataAsArray = new byte[] { ' ' };
		Either<? extends Component, Boolean> result;

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "deserializeComponent",
				new Object[] { ComponentCacheData.class, dataAsArray });
	}

	@Test
	public void testGetComponent_1() throws Exception {
		ComponentCache testSubject;
		String componentUid = "";
		Either<Component, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponent(componentUid);
	}

	@Test
	public void testGetComponent_2() throws Exception {
		ComponentCache testSubject;
		String componentUid = "";
		Long lastModificationTime = null;
		Either<Component, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponent(componentUid, lastModificationTime);
	}

	@Test
	public void testSetComponent() throws Exception {
		ComponentCache testSubject;
		String componentUid = "";
		Long lastModificationTime = null;
		NodeTypeEnum nodeTypeEnum = null;
		boolean result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.setComponent(componentUid, lastModificationTime, nodeTypeEnum);
	}

	@Test
	public void testSaveComponent() throws Exception {
		ComponentCache testSubject;
		String componentUid = "";
		Long lastModificationTime = null;
		NodeTypeEnum nodeTypeEnum = null;
		Component component = null;
		boolean result;

		// default test
		testSubject = createTestSubject();
		result = Deencapsulation.invoke(testSubject, "saveComponent", componentUid, Long.class, NodeTypeEnum.class,
				Component.class);
	}

	@Test
	public void testSetComponent_1() throws Exception {
		ComponentCache testSubject;
		Component component = null;
		NodeTypeEnum nodeTypeEnum = null;
		boolean result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.setComponent(component, nodeTypeEnum);
	}

	@Test
	public void testGetComponentsFull_1() throws Exception {
	ComponentCache testSubject;Map<String,Long> filteredResources = null;
	Either<ImmutablePair<List<Component>,Set<String>>,ActionStatus> result;
	
	// default test
	testSubject=createTestSubject();result=Deencapsulation.invoke(testSubject, "getComponentsFull", Map.class);
	}

	@Test
	public void testGetComponentsForCatalog_1() throws Exception {
		ComponentCache testSubject;
		Map<String, Long> components = null;
		ComponentTypeEnum componentTypeEnum = null;
		Either<ImmutablePair<List<Component>, Set<String>>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponentsForCatalog(components, componentTypeEnum);
	}

	@Test
	public void testGetComponents_1() throws Exception {
		ComponentCache testSubject;
		Map<String, Long> components = null;
		Function<List<Component>, List<Component>> filterFieldsFunc = null;
		Either<ImmutablePair<List<Component>, Set<String>>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponents(components, filterFieldsFunc);
	}

	@Test
	public void testGetComponentAndTime() throws Exception {
		ComponentCache testSubject;
		String componentUid = "";
		Function<Component, Component> filterFieldsFunc = null;
		Either<ImmutablePair<Component, Long>, ActionStatus> result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.getComponentAndTime(componentUid, filterFieldsFunc);
	}

	@Test
	public void testGetComponentFromCache() throws Exception {
	ComponentCache testSubject;String componentUid = "";
	Long lastModificationTime = null;
	Function<Component,Component> filterFieldsFunc = null;
	Either<ImmutablePair<Component,ComponentCacheData>,ActionStatus> result;
	
	// test 1
	testSubject=createTestSubject();lastModificationTime = null;
	result=Deencapsulation.invoke(testSubject, "getComponentFromCache", new Object[]{componentUid, Long.class, Function.class});
	Assert.assertEquals(null, result);
	
	// test 2
	testSubject=createTestSubject();filterFieldsFunc = null;
	result=Deencapsulation.invoke(testSubject, "getComponentFromCache", new Object[]{componentUid, Long.class, Function.class});
	Assert.assertEquals(null, result);
	}

	@Test
	public void testDeleteComponentFromCache() throws Exception {
		ComponentCache testSubject;
		String id = "";
		ActionStatus result;

		// default test
		testSubject = createTestSubject();
		result = testSubject.deleteComponentFromCache(id);
	}
}