unit tests - catalog-model
[sdc.git] / catalog-model / src / test / java / org / openecomp / sdc / be / model / CapabilityTypeDefinitionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  * Modifications copyright (c) 2019 Nokia
20  * ================================================================================
21  */
22
23 package org.openecomp.sdc.be.model;
24
25 import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSettersExcluding;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertThat;
28
29 import java.util.Collections;
30 import org.junit.Test;
31 import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition.OwnerType;
32 import org.openecomp.sdc.be.datatypes.elements.CapabilityTypeDataDefinition;
33 import org.openecomp.sdc.be.resources.data.CapabilityTypeData;
34
35 public class CapabilityTypeDefinitionTest {
36
37         private static final String OWNER_NAME = "ownerName";
38         private static final String NAME = "name";
39         private static final OwnerType RESOURCE = OwnerType.RESOURCE;
40         private static final String TYPE = "TYPE";
41         private static final String DESCRIPTION = "DESCRIPTION";
42         private static final String UNIQUE_ID = "UNIQUE_ID";
43
44         @Test
45         public void hasValidGettersAndSettersTest() {
46                 assertThat(CapabilityTypeDefinition.class,
47                         hasValidGettersAndSettersExcluding("empty", "ownerIdIfEmpty"));
48         }
49
50         @Test
51         public void shouldHaveValidToString() {
52                 CapabilityDefinition capabilityDefinition = new CapabilityDefinition(
53                         new CapabilityTypeDefinition(), OWNER_NAME, NAME, RESOURCE);
54                 capabilityDefinition.setProperties(Collections.emptyList());
55                 capabilityDefinition.setType(TYPE);
56                 capabilityDefinition.setDescription(DESCRIPTION);
57                 CapabilityTypeDefinition capabilityTypeDefinitionTest = new CapabilityTypeDefinition(capabilityDefinition);
58                 String toStringRepr = capabilityTypeDefinitionTest.toString();
59                 assertEquals(toStringRepr, "CapabilityTypeDataDefinition [uniqueId=null, description=DESCRIPTION, type=TYPE, validSourceTypes=[], version=null, creationTime=null, modificationTime=null] [ derivedFrom=null, properties={} ]");
60         }
61
62         @Test
63         public void shouldCreateCapabilityTypeDefinitionFromCapabilityTypeData() {
64                 CapabilityTypeData capabilityTypeData = new CapabilityTypeData();
65                 CapabilityTypeDataDefinition capabilityTypeDataDefinition = new CapabilityTypeDataDefinition();
66                 capabilityTypeDataDefinition.setUniqueId(UNIQUE_ID);
67                 capabilityTypeDataDefinition.setType(TYPE);
68                 capabilityTypeData.setCapabilityTypeDataDefinition(capabilityTypeDataDefinition);
69                 CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition(capabilityTypeData);
70                 assertEquals(capabilityTypeDefinition.getType(), capabilityTypeData.getCapabilityTypeDataDefinition().getType());
71                 assertEquals(capabilityTypeDefinition.getUniqueId(), capabilityTypeData.getCapabilityTypeDataDefinition().getUniqueId());
72         }
73 }