diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2023-08-17 22:09:58 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2023-09-22 15:58:23 +0100 |
commit | 42c18ef1c6506e63151b55a96d90362da9fbda63 (patch) | |
tree | 895c7598c35b8daad7ac5e2681bc0feed5a47027 /main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java | |
parent | eb4cf2ad5d004cbfda90a752d10fbc6e91ef8fb4 (diff) |
Java 17 / Spring 6 / Spring Boot 3 Upgrade
Issue-ID: POLICY-4671
Change-Id: I664e5f62b1ad23619888af98589c04875b07f4d3
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
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()) |