2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.db.catalog.test;
23 import static org.junit.Assert.assertTrue;
24 import static org.junit.Assert.fail;
26 import java.io.BufferedWriter;
28 import java.io.FileOutputStream;
29 import java.io.IOException;
30 import java.io.OutputStreamWriter;
31 import java.io.Writer;
32 import java.util.UUID;
34 import org.junit.Test;
35 import org.openecomp.mso.db.catalog.beans.HeatFiles;
40 public class HeatFilesTest {
43 public final void heatFilesTest() {
45 HeatFiles heatFiles = new HeatFiles();
46 heatFiles.setFileBody("testBody");
47 heatFiles.setArtifactUuid(UUID.randomUUID().toString());
48 assertTrue(heatFiles.getFileBody().equals("testBody"));
49 assertTrue(!heatFiles.toString().contains("8 chars"));
50 heatFiles.setFileBody(null);
51 assertTrue(!heatFiles.toString().contains("Not defined"));
52 heatFiles.setVersion("12");
53 assertTrue(heatFiles.getVersion().equals("12"));
55 heatFiles.setFileName("File");
56 assertTrue(heatFiles.getFileName().equalsIgnoreCase("File"));
58 heatFiles.setCreated(null);
59 assertTrue(heatFiles.getCreated() == null);
60 heatFiles.setAsdcUuid("asdc");
62 assertTrue(heatFiles.getAsdcUuid().equalsIgnoreCase("asdc"));
64 heatFiles.setDescription("desc");
65 assertTrue(heatFiles.getDescription().equalsIgnoreCase("desc"));
68 heatFiles.setArtifactChecksum("artifactChecksum");
69 assertTrue(heatFiles.getArtifactChecksum().equalsIgnoreCase("artifactChecksum"));
72 tempFile = File.createTempFile("heatFiles", "test");
73 tempFile.deleteOnExit();
74 try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile), "utf-8"))) {
75 writer.write("something\n");
76 writer.write("something2\n");
78 heatFiles.setFileBody(tempFile.getAbsolutePath());
79 assertTrue(heatFiles.getFileBody().contains("test"));
80 } catch (IOException e) {
82 fail("Exception caught");