summaryrefslogtreecommitdiffstats
path: root/docs/conf.py
AgeCommit message (Collapse)AuthorFilesLines
2019-02-22Fix build timeout & upgrade sphinxRich Bennett1-3/+4
Back out collapse_navigation change, it increases build time 6x Upgrade sphinx release 1.8.4 Change-Id: Ib2a4e85712416c96a8096753f0f119d73b7d6c90 Issue-ID: DOC-406 Signed-off-by: Rich Bennett <rb2745@att.com>
2019-02-20Sidebar enhancementAndrea Visnyei1-3/+4
Added the Architecture and the Setting up ONAP pages to the sidebar Issue-ID: DOC-401 Change-Id: I90261a5abf2aebd603692c05d6a7a29ce1decddc Signed-off-by: Andrea Visnyei <andrea.visnyei@nokia.com>
2019-02-19Merge "Copyright updated to 2019"Rich Bennett1-1/+1
2019-02-19Sticky navigationGergely Csatari1-1/+2
Modification of the configuration ina way that the navigation menu is always visible. Change-Id: Ie5dc8e5afed071f49ae575ceb4411fbc1ebc0f37 Issue-ID: DOC-404 Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>
2019-02-15Whitening the search backgroundGergely Csatari1-1/+1
The 0.4.3 version of sphinx_rtd_theme supports the possiblity to change background of the search area. This change modifies the background to white to make it inline with the ONAP logo. Issue-ID: DOC-402 Change-Id: I5156cf0ed146e12d9dbd2b5685a7ff563a88f6a2 Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>
2019-02-14Copyright updated to 2019<
/*-
 * ============LICENSE_START=======================================================
 *  Copyright (C) 2019-2021 Nordix Foundation.
 *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * 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.
 *
 * SPDX-License-Identifier: Apache-2.0
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.models.base;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.onap.policy.models.base.PfKey.Compatibility;
import org.onap.policy.models.base.testconcepts.DummyPfConceptKeySub;

public class PfKeyUseTest {

    private static final String OTHER_KEY_IS_NULL = "^otherKey is marked .*on.*ull but is null$";

    @Test
    public void testKeyUse() {
        assertNotNull(new PfKeyUse());
        assertNotNull(new PfKeyUse(new PfConceptKey()));
        assertNotNull(new PfKeyUse(new PfReferenceKey()));

        assertThatThrownBy(() -> new PfKeyUse((PfKeyUse) null))
            .hasMessageMatching("^copyConcept is marked .*on.*ull but is null$");

        PfConceptKey key = new PfConceptKey("Key", "0.0.1");
        PfKeyUse keyUse = new PfKeyUse();
        keyUse.setKey(key);
        assertEquals(key, keyUse.getKey());
        assertEquals("Key:0.0.1", keyUse.getId());
        assertEquals(key, keyUse.getKeys().get(0));
        assertFalse(keyUse.isNullKey());

        assertEquals(Compatibility.IDENTICAL, keyUse.getCompatibility(key));

        assertThatThrownBy(() -> key.getCompatibility(null)).hasMessageMatching(OTHER_KEY_IS_NULL);

        assertTrue(keyUse.isCompatible(key));

        keyUse.clean();
        assertNotNull(keyUse);

        assertNotNull(keyUse.validate(""));

        assertNotEquals(0, keyUse.hashCode());

        PfKeyUse clonedKeyUse = new PfKeyUse(keyUse);
        assertEquals("PfKeyUse(usedKey=PfConceptKey(name=Key, version=0.0.1))", clonedKeyUse.toString());

        assertNotEquals(0, keyUse.hashCode());

        assertEquals(keyUse, keyUse);
        assertEquals(keyUse, clonedKeyUse);
        assertNotEquals(keyUse, "Hello");
        assertEquals(keyUse, new PfKeyUse(key));

        assertEquals(0, keyUse.compareTo(keyUse));
        assertEquals(0, keyUse.compareTo(clonedKeyUse));
        assertNotEquals(0, keyUse.compareTo(new PfConceptKey()));
        assertEquals(0, keyUse.compareTo(new PfKeyUse(key)));
    }

    @Test
    public void testNullKey() {
        PfKeyUse keyUseNull = new PfKeyUse(PfConceptKey.getNullKey());
        PfKeyUse keyUse = new PfKeyUse();
        assertEquals(false, keyUseNull.validate("").isValid());

        assertThatThrownBy(() -> keyUse.setKey(null)).hasMessageMatching("^key is marked .*on.*ull but is null$");

        assertThatThrownBy(() -> keyUse.getCompatibility(null)).hasMessageMatching(OTHER_KEY_IS_NULL);

        assertThatThrownBy(() -> keyUse.isCompatible(null)).hasMessageMatching(OTHER_KEY_IS_NULL);

        assertThatThrownBy(() -> keyUse.validate(null))
                        .hasMessageMatching("^fieldName is marked .*on.*ull but is null$");

        PfKeyUse testKeyUse = new PfKeyUse(new DummyPfConceptKeySub(new PfConceptKey()));
        assertEquals(testKeyUse, new PfKeyUse(testKeyUse));

        assertThatThrownBy(() -> new PfKeyUse((PfKeyUse) null)).isInstanceOf(NullPointerException.class);

        assertThatThrownBy(() -> keyUse.isNewerThan(null)).hasMessageMatching(OTHER_KEY_IS_NULL);

        assertEquals(false, testKeyUse.isNewerThan(keyUse));
        assertEquals(false, testKeyUse.isNewerThan(testKeyUse));

        assertEquals(0, testKeyUse.getMajorVersion());
        assertEquals(0, testKeyUse.getMinorVersion());
        assertEquals(0, testKeyUse.getPatchVersion());
    }
}