diff options
Diffstat (limited to 'main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java index d5c19fe3..7b64c47f 100644 --- a/main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP PAP * ================================================================================ - * Copyright (C) 2022, Nordix Foundation. All rights reserved. + * Copyright (C) 2022-2023 Nordix Foundation. 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. @@ -25,13 +25,13 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.MockitoAnnotations; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardYamlCoder; @@ -43,8 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate; import org.onap.policy.pap.main.repository.ToscaNodeTemplateRepository; -@RunWith(MockitoJUnitRunner.class) -public class ToscaNodeTemplateServiceTest { +class ToscaNodeTemplateServiceTest { private static final String NODE_TEMPLATE_NAME = "tca_metadata"; private static final String NODE_TEMPLATE_VERSION = "1.0.0"; @@ -57,24 +56,31 @@ public class ToscaNodeTemplateServiceTest { private ToscaNodeTemplate nodeTemplate = new ToscaNodeTemplate(); - private StandardCoder coder = new StandardYamlCoder(); + private final StandardCoder coder = new StandardYamlCoder(); + + AutoCloseable autoCloseable; /** * Set up for tests. - * */ - @Before + @BeforeEach public void setup() throws CoderException { + autoCloseable = MockitoAnnotations.openMocks(this); coder.decode(ResourceUtils.getResourceAsString("e2e/policyMetadataSet.yaml"), - ToscaServiceTemplate.class).getToscaTopologyTemplate().getNodeTemplates() + ToscaServiceTemplate.class).getToscaTopologyTemplate().getNodeTemplates() .forEach((key, value) -> nodeTemplate = value); Mockito.when(nodeTemplateRepository.findById(new PfConceptKey(NODE_TEMPLATE_NAME, NODE_TEMPLATE_VERSION))) .thenReturn(Optional.of(new JpaToscaNodeTemplate(nodeTemplate))); } + @AfterEach + public void tearDown() throws Exception { + autoCloseable.close(); + } + @Test - public void testGetToscaNodeTemplate() { + void testGetToscaNodeTemplate() { assertDoesNotThrow(() -> nodeTemplateService.getToscaNodeTemplate(NODE_TEMPLATE_NAME, NODE_TEMPLATE_VERSION)); assertThat(nodeTemplateService.getToscaNodeTemplate(NODE_TEMPLATE_NAME, NODE_TEMPLATE_VERSION).getMetadata()) |