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 {
30 public void testMd5NormalDiff(){
31 String contents1 = "contents1";
32 String contents2 = "contents2";
34 assertThat(Md5Util.md5(contents1), not(equalTo(Md5Util.md5(contents2))));
38 public void testMd5NormalSame(){
39 String contents1 = "contents";
40 String contents2 = "contents";
42 assertThat(Md5Util.md5(contents1), equalTo(Md5Util.md5(contents2)));
46 public void testMd5Null(){
47 String contents1 = null;
48 String contents2 = null;
50 assertThat(Md5Util.md5(contents1), equalTo(Md5Util.md5(contents2)));
54 public void testMd5ObjDiff(){
55 DcaeConfigurations config1 = new DcaeConfigurations();
56 DcaeConfigurations config2 = new DcaeConfigurations();
58 config1.addPubSecInfo("config1", new SecurityInfo());
59 config2.addPubSecInfo("config2", new SecurityInfo());
62 assertThat(Md5Util.md5(config1), not(equalTo(Md5Util.md5(config2))));
63 } catch (JsonProcessingException e) {
69 public void testMd5ObjSame(){
70 DcaeConfigurations config1 = new DcaeConfigurations();
71 DcaeConfigurations config2 = new DcaeConfigurations();
73 config1.addPubSecInfo("config", new SecurityInfo());
74 config2.addPubSecInfo("config", new SecurityInfo());
77 assertThat(Md5Util.md5(config1), equalTo(Md5Util.md5(config2)));
78 } catch (JsonProcessingException e) {