summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/test/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDtoTest.java
blob: 3c66a322df79c4c95ff73261866cb4d328c37416 (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
13
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
/*
 * Copyright © 2016-2018 European Support Limited
 *
 * 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.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openecomp.sdcrests.vendorlicense.rest.mapping;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto;
import org.junit.jupiter.api.Test;


class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDtoTest {

    @Test
    void testReferencingFeatureGroups() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        Set<String> param = new HashSet<>(Collections.singletonList("c7797917-7548-44c2-93b9-cf72f27bca3f"));
        source.setReferencingFeatureGroups(param);
        mapper.doMapping(source, target);
        assertEquals(target.getReferencingFeatureGroups(), param);
    }

    @Test
    void testDescription() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        String param = "f026c265-d91f-4c47-8f3b-2600be5023dc";
        source.setDescription(param);
        mapper.doMapping(source, target);
        assertEquals(target.getDescription(), param);
    }

    @Test
    void testType() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        LicenseKeyType licenseKeyType = LicenseKeyType.Universal;
        source.setType(licenseKeyType);
        mapper.doMapping(source, target);
        assertEquals(target.getType(), licenseKeyType);
    }

    @Test
    void testIncrements() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        String param = "813639e7-45d6-4443-8a7c-a955d34a931a";
        source.setIncrements(param);
        mapper.doMapping(source, target);
        assertEquals(target.getIncrements(), param);
    }

    @Test
    void testExpiryDate() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        String param = "d7925c8e-239f-44a3-9b24-67ddbd9467c2";
        source.setExpiryDate(param);
        mapper.doMapping(source, target);
        assertEquals(target.getExpiryDate(), param);
    }

    @Test
    void testId() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        String param = "b2f35aa5-0240-46b7-bade-35890d46e9f9";
        source.setId(param);
        mapper.doMapping(source, target);
        assertEquals(target.getId(), param);
    }

    @Test
    void testThresholdUnits() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        ThresholdUnit thresholdUnit = ThresholdUnit.Absolute;
        source.setThresholdUnits(thresholdUnit);
        mapper.doMapping(source, target);
        assertEquals(target.getThresholdUnits(), thresholdUnit);
    }

    @Test
    void testThresholdValue() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        Integer param = 1144092791;
        source.setThresholdValue(param);
        mapper.doMapping(source, target);
        assertEquals(target.getThresholdValue(), param);
    }

    @Test
    void testName() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        String param = "8fb07080-e7ea-4543-812c-1ecdbb9e82c9";
        source.setName(param);
        mapper.doMapping(source, target);
        assertEquals(target.getName(), param);
    }

    @Test
    void testOperationalScope() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        MultiChoiceOrOther<OperationalScope> operationalScopeMultiChoiceOrOther = new MultiChoiceOrOther<>();
        Set set = new HashSet<>();
        set.add(TestEnum.Yes);
        operationalScopeMultiChoiceOrOther.setChoices(set);
        source.setOperationalScope(operationalScopeMultiChoiceOrOther);
        mapper.doMapping(source, target);
        assertEquals(target.getOperationalScope().getChoices(), operationalScopeMultiChoiceOrOther.getChoices());
    }

    @Test
    void testStartDate() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper =
                new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        String param = "75f2ae76-b32f-4ac1-92f6-a9d92cb41160";
        source.setStartDate(param);
        mapper.doMapping(source, target);
        assertEquals(target.getStartDate(), param);
    }

    @Test
    void testManufacturerReferenceNumber() {
        LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
        LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
        MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper = new
            MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
        String param = "02402e1e-7092-485a-9574-46e2d49cca97";
        source.setManufacturerReferenceNumber(param);
        mapper.doMapping(source, target);
        assertEquals(target.getManufacturerReferenceNumber(), param);
    }

    enum TestEnum {
        Yes
    }
}