summaryrefslogtreecommitdiffstats
path: root/docs/media
AgeCommit message (Collapse)AuthorFilesLines
2019-04-26Overview document createdNoemi Wagner1-1/+1
The overview document targets to provide the reader with a basic understanding on ONAP and its basic functional description.The doc also provides insight to Benefit of ONAP, licenses needed, basic releases etc. Issue-ID: DOC-364 Change-Id: I87c10896dc308d24d5aa8b54d920545372ffc41d Signed-off-by: Noemi Wagner <noemi.wagner@nokia.com>
2018-12-05New landing page structureNoemi Wagner3-0/+138
On the landing page there was no generic and basic info on ONAP yet, this has been added. A new architecture figure has been created. ONAP documentation was made available from this main landing page as well. The side bar of the landing page has also been changed. So far the section of the Release note have been made available from here, but now only the main doc titles are listed. Issue-ID: DOC-351 Change-Id: I381c8e232438c51211a8a9303ea3589ebea4d4a4 Signed-off-by: Noemi Wagner <noemi.wagner@nokia.com>
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
/*-
 * ============LICENSE_START=======================================================
 * Copyright (C) 2018 Ericsson. All rights reserved.
 * Modifications Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
 * Modifications Copyright (C) 2019 Nordix Foundation.
 * ================================================================================
 * 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.
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.controlloop.policy.guard;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.util.LinkedList;
import java.util.List;

import org.junit.Test;

public class GuardPolicyTest {

    private static final String GUARD_DESCRIPTION = "guard description";
    private static final String GUARD_ID = "guard id";
    private static final String GUARD_NAME = "guard name";

    @Test
    public void testConstructor() {
        GuardPolicy guardPolicy = new GuardPolicy();

        assertNotNull(guardPolicy.getId());
        assertNull(guardPolicy.getName());
        assertNull(guardPolicy.getDescription());
        assertNull(guardPolicy.getMatch_parameters());
        assertNull(guardPolicy.getLimit_constraints());
    }

    @Test
    public void testConstructorString() {
        String id = GUARD_ID;
        GuardPolicy guardPolicy = new GuardPolicy(id);

        assertEquals(id, guardPolicy.getId());
        assertNull(guardPolicy.getName());
        assertNull(guardPolicy.getDescription());
        assertNull(guardPolicy.getMatch_parameters());
        assertNull(guardPolicy.getLimit_constraints());
    }

    @Test
    public void testConstructorStringStringStringMatchParameters() {
        String id = GUARD_ID;
        String name = GUARD_NAME;
        String description = GUARD_DESCRIPTION;
        MatchParameters matchParameters = new MatchParameters();
        List<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        GuardPolicy guardPolicy = new GuardPolicy(id, name, description, matchParameters);

        assertNotNull(guardPolicy.getId());
        assertEquals(name, guardPolicy.getName());
        assertEquals(description, guardPolicy.getDescription());
        assertEquals(matchParameters, guardPolicy.getMatch_parameters());
        assertNull(guardPolicy.getLimit_constraints());
    }

    @Test
    public void testConstructorStringMatchParametersList() {
        String name = GUARD_NAME;
        MatchParameters matchParameters = new MatchParameters();
        List<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        GuardPolicy guardPolicy = new GuardPolicy(name, matchParameters, limitConstraints);

        assertNotNull(guardPolicy.getId());
        assertEquals(name, guardPolicy.getName());
        assertNull(guardPolicy.getDescription());
        assertEquals(matchParameters, guardPolicy.getMatch_parameters());
        assertEquals(limitConstraints, guardPolicy.getLimit_constraints());
    }

    @Test
    public void testConstructorStringStringMatchParametersList() {
        String name = GUARD_NAME;
        String description = GUARD_DESCRIPTION;
        MatchParameters matchParameters = new MatchParameters();
        List<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        GuardPolicy guardPolicy = new GuardPolicy(name, description, matchParameters, limitConstraints);

        assertNotNull(guardPolicy.getId());
        assertEquals(name, guardPolicy.getName());
        assertEquals(description, guardPolicy.getDescription());
        assertEquals(matchParameters, guardPolicy.getMatch_parameters());
        assertEquals(limitConstraints, guardPolicy.getLimit_constraints());
    }

    @Test
    public void testConstructorStringStringStringMatchParametersList() {
        String id = GUARD_ID;
        String name = GUARD_NAME;
        String description = GUARD_DESCRIPTION;
        MatchParameters matchParameters = new MatchParameters();
        List<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        GuardPolicy guardPolicy = new GuardPolicy(id, name, description, matchParameters, limitConstraints);

        assertEquals(id, guardPolicy.getId());
        assertEquals(name, guardPolicy.getName());
        assertEquals(description, guardPolicy.getDescription());
        assertEquals(matchParameters, guardPolicy.getMatch_parameters());
        assertEquals(limitConstraints, guardPolicy.getLimit_constraints());
    }

    @Test
    public void testConstructorGuardPolicy() {
        String id = GUARD_ID;
        String name = GUARD_NAME;
        String description = GUARD_DESCRIPTION;
        MatchParameters matchParameters = new MatchParameters();
        List<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        GuardPolicy guardPolicy1 = new GuardPolicy(id, name, description, matchParameters, limitConstraints);

        GuardPolicy guardPolicy2 = new GuardPolicy(guardPolicy1);


        assertEquals(id, guardPolicy2.getId());
        assertEquals(name, guardPolicy2.getName());
        assertEquals(description, guardPolicy2.getDescription());
        assertEquals(matchParameters, guardPolicy2.getMatch_parameters());
        assertEquals(limitConstraints, guardPolicy2.getLimit_constraints());
    }

    @Test
    public void testSetAndGetId() {
        String id = GUARD_ID;
        GuardPolicy guardPolicy = new GuardPolicy();
        guardPolicy.setId(id);
        assertEquals(id, guardPolicy.getId());
    }

    @Test
    public void testSetAndGetName() {
        String name = GUARD_NAME;
        GuardPolicy guardPolicy = new GuardPolicy();
        guardPolicy.setName(name);
        assertEquals(name, guardPolicy.getName());
    }

    @Test
    public void testSetAndGetDescription() {
        String description = GUARD_DESCRIPTION;
        GuardPolicy guardPolicy = new GuardPolicy();
        guardPolicy.setDescription(description);
        assertEquals(description, guardPolicy.getDescription());
    }

    @Test
    public void testSetAndGetMatchParameters() {
        MatchParameters matchParameters = new MatchParameters();
        GuardPolicy guardPolicy = new GuardPolicy();
        guardPolicy.setMatch_parameters(matchParameters);
        assertEquals(matchParameters, guardPolicy.getMatch_parameters());
    }

    @Test
    public void testSetAndGetLimitConstraints() {
        LinkedList<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        GuardPolicy guardPolicy = new GuardPolicy();
        guardPolicy.setLimit_constraints(limitConstraints);
        assertEquals(limitConstraints, guardPolicy.getLimit_constraints());
    }

    @Test
    public void testIsValid() {
        GuardPolicy guardPolicy = new GuardPolicy();
        assertFalse(guardPolicy.isValid());

        guardPolicy.setName(GUARD_NAME);
        assertTrue(guardPolicy.isValid());

        guardPolicy.setId(null);
        assertFalse(guardPolicy.isValid());
    }

    @Test
    public void testToString() {
        String id = GUARD_ID;
        String name = GUARD_NAME;
        String description = GUARD_DESCRIPTION;
        MatchParameters matchParameters = new MatchParameters();
        List<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        GuardPolicy guardPolicy = new GuardPolicy(id, name, description, matchParameters, limitConstraints);

        assertEquals(guardPolicy.toString(), "Policy [id=guard id, name=guard name, description=guard description, "
                + "match_parameters=MatchParameters [controlLoopName=null, actor=null, recipe=null, targets=null], "
                + "limitConstraints=[Constraint [freq_limit_per_target=null, time_window=null, active_time_range=null,"
                + " blacklist=null]]]", guardPolicy.toString());
    }

    @Test
    public void testEquals() {
        final String id = GUARD_ID;
        final String name = GUARD_NAME;
        final String description = GUARD_DESCRIPTION;
        GuardPolicy guardPolicy1 = new GuardPolicy(id);
        GuardPolicy guardPolicy2 = new GuardPolicy();
        assertFalse(guardPolicy1.equals(guardPolicy2));

        guardPolicy2.setId(id);
        assertTrue(guardPolicy1.equals(guardPolicy2));
        assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode());

        guardPolicy1.setName(name);
        assertFalse(guardPolicy1.equals(guardPolicy2));
        guardPolicy2.setName(name);
        assertTrue(guardPolicy1.equals(guardPolicy2));
        assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode());

        guardPolicy1.setDescription(description);
        assertFalse(guardPolicy1.equals(guardPolicy2));
        guardPolicy2.setDescription(description);
        assertTrue(guardPolicy1.equals(guardPolicy2));
        assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode());

        MatchParameters matchParameters = new MatchParameters();
        guardPolicy1.setMatch_parameters(matchParameters);
        assertFalse(guardPolicy1.equals(guardPolicy2));
        guardPolicy2.setMatch_parameters(matchParameters);
        assertTrue(guardPolicy1.equals(guardPolicy2));
        assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode());

        LinkedList<Constraint> limitConstraints = new LinkedList<>();
        limitConstraints.add(new Constraint());
        guardPolicy1.setLimit_constraints(limitConstraints);
        assertFalse(guardPolicy1.equals(guardPolicy2));
        guardPolicy2.setLimit_constraints(limitConstraints);
        assertTrue(guardPolicy1.equals(guardPolicy2));
        assertEquals(guardPolicy1.hashCode(), guardPolicy2.hashCode());
    }

    @Test
    public void testEqualsSameObject() {
        GuardPolicy guardPolicy = new GuardPolicy();
        assertTrue(guardPolicy.equals(guardPolicy));
    }

    @Test
    public void testEqualsNull() {
        GuardPolicy guardPolicy = new GuardPolicy();
        assertFalse(guardPolicy.equals(null));
    }

    @Test
    public void testEqualsInstanceOfDiffClass() {
        GuardPolicy guardPolicy = new GuardPolicy();
        assertFalse(guardPolicy.equals(""));
    }
}