diff options
Diffstat (limited to 'appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java')
-rw-r--r-- | appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java b/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java index 8bb1451dd..c59d5d488 100644 --- a/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java +++ b/appc-dg-util/appc-dg-util-bundle/src/test/java/org/onap/appc/dg/util/impl/UpgradeStubNodeImplTest.java @@ -6,6 +6,8 @@ * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= + * Copyright (C) 2018 Nokia + * ============================================================================= * 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 @@ -23,40 +25,59 @@ package org.onap.appc.dg.util.impl; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.mockito.Mockito.verifyZeroInteractions; + +import java.util.HashMap; +import java.util.Map; import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.appc.dg.util.UpgradeStubNode; import org.onap.appc.exceptions.APPCException; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.adaptors.aai.AAIClient; -import org.onap.ccsdk.sli.adaptors.aai.AAIService; - -import java.util.HashMap; -import java.util.Map; +@RunWith(MockitoJUnitRunner.class) public class UpgradeStubNodeImplTest { + @Mock private SvcLogicContext svcLogicContext; - private UpgradeStubNodeImpl upgradeStubNode; + private UpgradeStubNode upgradeStubNode; @Before - public void setUp() throws Exception { + public void setUp() { upgradeStubNode = new UpgradeStubNodeImpl(); } @Test - public void testHandleUpgradeStubSuccess() throws APPCException { + public void handleUpgradeStub_shouldCompleteSuccessfully_whenFailureIndicatorIsNull() throws APPCException { Map<String, String> params = new HashMap<>(); upgradeStubNode.handleUpgradeStub(params, svcLogicContext); + verifyZeroInteractions(svcLogicContext); } - @Test(expected = APPCException.class) - public void testHandleUpgradeStubException() throws APPCException { + @Test + public void handleUpgradeStub_shouldCompleteSuccessfully_whenFailureIndicatorIsFalse() throws APPCException { + // GIVEN Map<String, String> params = new HashMap<>(); - params.put("failureIndicator", "true"); + params.put("failureIndicator", "false"); + // WHEN upgradeStubNode.handleUpgradeStub(params, svcLogicContext); + // THEN + verifyZeroInteractions(svcLogicContext); + } + + @Test + public void handleUpgradeStub_shouldThrowAPPCException_whenFailureIndicatorIsTrue() throws APPCException { + // GIVEN + Map<String, String> params = new HashMap<>(); + params.put("failureIndicator", "true"); + // WHEN // THEN + assertThatExceptionOfType(APPCException.class) + .isThrownBy(() -> upgradeStubNode.handleUpgradeStub(params, svcLogicContext)); + verifyZeroInteractions(svcLogicContext); } }
\ No newline at end of file |