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.batch.test;
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.batch.actions.Message;
33 import org.onap.aaf.auth.batch.helpers.Creator;
34 import org.onap.aaf.auth.batch.helpers.Notification;
35 import org.onap.aaf.auth.batch.helpers.Notification.TYPE;
36 import org.onap.aaf.auth.batch.helpers.creators.RowCreator;
37 import org.onap.aaf.auth.env.AuthzTrans;
38 import org.onap.aaf.misc.env.Env;
39 import org.onap.aaf.misc.env.LogTarget;
40 import org.onap.aaf.misc.env.TimeTaken;
42 public class JU_NotificationTest {
45 private AuthzTrans trans;
47 private Creator<Notification> creator;
52 private LogTarget logTarget;
56 public void setUp() throws Exception {
60 msg.line("%n", "Message");
62 when(trans.info()).thenReturn(logTarget);
63 when(trans.start("Load Notify", Env.REMOTE)).thenReturn(tt);
68 Notification notification = Notification.create("user", TYPE.CN);
69 assertEquals(notification.checksum(), 0);
70 notification.set(msg);
71 assertEquals(notification.checksum(), 10);
72 assertNull(Notification.get("user", TYPE.CN));
73 assertTrue(notification.update(trans, null, true));
74 assertTrue(notification.toString().contains("\"user\",\"CN\","));
76 Notification.v2_0_18.create(RowCreator.getRow());
77 assertEquals(Notification.v2_0_18.select(), "SELECT user,type,last,checksum FROM authz.notify LIMIT 100000");