aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/test/java/org/onap/policy/pap/main/service/ToscaNodeTemplateServiceTest.java
diff options
context:
space:
mode:
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.java27
1 files changed, 18 insertions, 9 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..7aefdc4c 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,12 +25,14 @@ 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.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -44,7 +46,7 @@ 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 +59,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())