2 * Copyright 2017 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.holmes.common.utils;
19 import static org.hamcrest.core.IsEqual.equalTo;
20 import static org.hamcrest.core.IsNot.not;
21 import static org.junit.Assert.assertThat;
23 import com.fasterxml.jackson.core.JsonProcessingException;
24 import org.junit.Test;
25 import org.onap.holmes.common.dcae.entity.DcaeConfigurations;
26 import org.onap.holmes.common.dcae.entity.SecurityInfo;
28 public class Md5UtilTest {
31 public void testMd5NormalDiff() {
32 String contents1 = "contents1";
33 String contents2 = "contents2";
35 assertThat(Md5Util.md5(contents1), not(equalTo(Md5Util.md5(contents2))));
39 public void testMd5NormalSame() {
40 String contents1 = "contents";
41 String contents2 = "contents";
43 assertThat(Md5Util.md5(contents1), equalTo(Md5Util.md5(contents2)));
47 public void testMd5Null() {
48 String contents1 = null;
49 String contents2 = null;
51 assertThat(Md5Util.md5(contents1), equalTo(Md5Util.md5(contents2)));
55 public void testMd5ObjDiff() {
56 DcaeConfigurations config1 = new DcaeConfigurations();
57 DcaeConfigurations config2 = new DcaeConfigurations();
59 config1.addPubSecInfo("config1", new SecurityInfo());
60 config2.addPubSecInfo("config2", new SecurityInfo());
61 assertThat(Md5Util.md5(config1), not(equalTo(Md5Util.md5(config2))));
66 public void testMd5ObjSame() {
67 DcaeConfigurations config1 = new DcaeConfigurations();
68 DcaeConfigurations config2 = new DcaeConfigurations();
70 config1.addPubSecInfo("config", new SecurityInfo());
71 config2.addPubSecInfo("config", new SecurityInfo());
73 assertThat(Md5Util.md5(config1), equalTo(Md5Util.md5(config2)));