Catalog alignment
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / facade / operations / FacadeUserCacheOperationTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2020 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.sdc.be.facade.operations;
22
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.mockito.ArgumentCaptor;
27 import org.mockito.Captor;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.mockito.junit.MockitoJUnitRunner;
31 import org.openecomp.sdc.be.catalog.impl.DmaapProducer;
32 import org.openecomp.sdc.be.user.UserMessage;
33 import org.openecomp.sdc.be.user.UserOperationEnum;
34
35 import static org.assertj.core.api.Assertions.assertThat;
36
37 @RunWith(MockitoJUnitRunner.class)
38 public class FacadeUserCacheOperationTest {
39     @Mock
40     private DmaapProducer msProducer;
41     @Captor
42     private ArgumentCaptor<UserMessage> messageCaptor;
43     
44     private UserOperation userCacheOperation;
45     
46     @Before
47     public void setUp() {
48         userCacheOperation = new UserOperation(msProducer);
49     }
50
51     @Test
52     public void testUpdate() {
53         userCacheOperation.updateUserCache(UserOperationEnum.CREATE, "id", "role");
54         Mockito.verify(msProducer).pushMessage(messageCaptor.capture());
55         
56         UserMessage message = messageCaptor.getValue();
57         
58         assertThat(message.getOperation()).isEqualTo(UserOperationEnum.CREATE);
59         assertThat(message.getUserId()).isEqualTo("id");
60         assertThat(message.getRole()).isEqualTo("role");
61     }
62
63 }