2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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.onap.aaf.auth.helpers;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.assertTrue;
26 import static org.mockito.Mockito.when;
27 import static org.mockito.MockitoAnnotations.initMocks;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.mockito.Mock;
32 import org.onap.aaf.auth.actions.Message;
33 import org.onap.aaf.auth.env.AuthzTrans;
34 import org.onap.aaf.auth.helpers.Notification.TYPE;
35 import org.onap.aaf.auth.helpers.creators.RowCreator;
36 import org.onap.aaf.misc.env.Env;
37 import org.onap.aaf.misc.env.LogTarget;
38 import org.onap.aaf.misc.env.TimeTaken;
40 public class JU_NotificationTest {
43 private AuthzTrans trans;
45 private Creator<Notification> creator;
50 private LogTarget logTarget;
54 public void setUp() throws Exception {
58 msg.line("%n", "Message");
60 when(trans.info()).thenReturn(logTarget);
61 when(trans.start("Load Notify", Env.REMOTE)).thenReturn(tt);
66 Notification notification = Notification.create("user", TYPE.CN);
67 assertEquals(notification.checksum(), 0);
68 notification.set(msg);
69 assertEquals(notification.checksum(), 10);
70 assertNull(Notification.get("user", TYPE.CN));
71 assertTrue(notification.update(trans, null, true));
72 assertTrue(notification.toString().contains("\"user\",\"CN\","));
74 Notification.v2_0_18.create(RowCreator.getRow());
75 assertEquals(Notification.v2_0_18.select(), "SELECT user,type,last,checksum FROM authz.notify LIMIT 100000");