dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2019 AT&T Intellectual Property |
| 3 | // Copyright 2019 Nokia |
| 4 | // |
| 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
| 16 | |
| 17 | // This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 18 | // platform project (RICP). |
| 19 | |
| 20 | package reader |
| 21 | |
| 22 | import ( |
| 23 | "testing" |
| 24 | "github.com/stretchr/testify/assert" |
| 25 | ) |
| 26 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 27 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 28 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 29 | func initSdlInstanceMockTest() (sdlInstanceMockTest *MockSdlInstance) { |
| 30 | sdlInstanceMockTest = new(MockSdlInstance) |
| 31 | return |
| 32 | } |
| 33 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 34 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 35 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 36 | func TestRemoveAll(t *testing.T){ |
| 37 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 38 | sdlInstanceMockTest.On("RemoveAll").Return(nil) |
| 39 | err := sdlInstanceMockTest.RemoveAll() |
| 40 | assert.Nil(t, err) |
| 41 | } |
| 42 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 43 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 44 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 45 | func TestRemove(t *testing.T){ |
| 46 | var data []string |
| 47 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 48 | sdlInstanceMockTest.On("Remove", []string(data)).Return(nil) |
| 49 | err := sdlInstanceMockTest.Remove(data) |
| 50 | assert.Nil(t, err) |
| 51 | |
| 52 | } |
| 53 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 54 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 55 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 56 | func TestRemoveIf(t *testing.T){ |
| 57 | var data map[string]interface{} |
| 58 | key := "key" |
| 59 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 60 | sdlInstanceMockTest.On("RemoveIf", key, data).Return(true,nil) |
| 61 | res, err := sdlInstanceMockTest.RemoveIf(key, data) |
| 62 | assert.Nil(t, err) |
| 63 | assert.NotNil(t, res) |
| 64 | |
| 65 | } |
| 66 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 67 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 68 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 69 | func TestRemoveGroup(t *testing.T){ |
| 70 | group := "group" |
| 71 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 72 | sdlInstanceMockTest.On("RemoveGroup", group).Return(nil) |
| 73 | err := sdlInstanceMockTest.RemoveGroup(group) |
| 74 | assert.Nil(t, err) |
| 75 | |
| 76 | } |
| 77 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 78 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 79 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 80 | func TestRemoveIfAndPublish(t *testing.T){ |
| 81 | var data map[string]interface{} |
| 82 | var channelsAndEvents []string |
| 83 | key := "key" |
| 84 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 85 | sdlInstanceMockTest.On("RemoveIfAndPublish", channelsAndEvents, key, data).Return(true,nil) |
| 86 | res, err := sdlInstanceMockTest.RemoveIfAndPublish(channelsAndEvents, key, data) |
| 87 | assert.Nil(t, err) |
| 88 | assert.NotNil(t, res) |
| 89 | |
| 90 | } |
| 91 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 92 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 93 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 94 | func TestRemoveAndPublish(t *testing.T){ |
| 95 | var channelsAndEvents []string |
| 96 | var keys []string |
| 97 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 98 | sdlInstanceMockTest.On("RemoveAndPublish", []string(channelsAndEvents), []string(keys)).Return(nil) |
| 99 | err := sdlInstanceMockTest.RemoveAndPublish(channelsAndEvents, keys) |
| 100 | assert.Nil(t, err) |
| 101 | } |
| 102 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 103 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 104 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 105 | func TestRemoveAllAndPublish(t *testing.T){ |
| 106 | var channelsAndEvents []string |
| 107 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 108 | sdlInstanceMockTest.On("RemoveAllAndPublish", []string(channelsAndEvents)).Return(nil) |
| 109 | err := sdlInstanceMockTest.RemoveAllAndPublish(channelsAndEvents) |
| 110 | assert.Nil(t, err) |
| 111 | } |
| 112 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 113 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 114 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 115 | func TestIsMember(t *testing.T){ |
| 116 | var ret map[string]interface{} |
| 117 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 118 | sdlInstanceMockTest.On("IsMember", "group", ret).Return(true,nil) |
| 119 | res, err := sdlInstanceMockTest.IsMember("group", ret) |
| 120 | assert.Nil(t, err) |
| 121 | assert.NotNil(t, res) |
| 122 | } |
| 123 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 124 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 125 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 126 | func TestClose(t *testing.T){ |
| 127 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 128 | sdlInstanceMockTest.On("Close").Return(nil) |
| 129 | err := sdlInstanceMockTest.Close() |
| 130 | assert.Nil(t, err) |
| 131 | } |
| 132 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 133 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 134 | //should be used instead. |
dhirajverma | 7ea1548 | 2021-06-08 15:46:51 +0300 | [diff] [blame] | 135 | func TestSetIfNotExists(t *testing.T){ |
| 136 | var data map[string]interface{} |
| 137 | key := "key" |
| 138 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 139 | sdlInstanceMockTest.On("SetIfNotExists", key, data).Return(true,nil) |
| 140 | res, err := sdlInstanceMockTest.SetIfNotExists(key, data) |
| 141 | assert.Nil(t, err) |
| 142 | assert.NotNil(t, res) |
| 143 | } |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 144 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 145 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 146 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 147 | func TestAddMember(t *testing.T){ |
| 148 | var ret []interface{} |
| 149 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 150 | sdlInstanceMockTest.On("AddMember", "group", []interface{}{ret}).Return(nil) |
| 151 | err := sdlInstanceMockTest.AddMember("group", ret) |
| 152 | assert.Nil(t, err) |
| 153 | } |
| 154 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 155 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 156 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 157 | func TestRemoveMember(t *testing.T){ |
| 158 | var ret []interface{} |
| 159 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 160 | sdlInstanceMockTest.On("RemoveMember", "group", []interface{}{ret}).Return(nil) |
| 161 | err := sdlInstanceMockTest.RemoveMember("group", ret) |
| 162 | assert.Nil(t, err) |
| 163 | } |
| 164 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 165 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 166 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 167 | func TestSetAndPublish(t *testing.T){ |
| 168 | var pairs []interface{} |
| 169 | var channelsAndEvents []string |
| 170 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 171 | sdlInstanceMockTest.On("SetAndPublish", channelsAndEvents, []interface{}{pairs}).Return(nil) |
| 172 | err := sdlInstanceMockTest.SetAndPublish(channelsAndEvents, pairs) |
| 173 | assert.Nil(t, err) |
| 174 | } |
| 175 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 176 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 177 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 178 | func TestSetIfAndPublish(t *testing.T){ |
| 179 | var newData map[string]interface{} |
| 180 | var oldData map[string]interface{} |
| 181 | var group []string |
| 182 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 183 | sdlInstanceMockTest.On("SetIfAndPublish", group, "key", oldData, newData).Return(true, nil) |
| 184 | res, err := sdlInstanceMockTest.SetIfAndPublish(group, "key", oldData, newData) |
| 185 | assert.Nil(t, err) |
| 186 | assert.NotNil(t, res) |
| 187 | } |
| 188 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 189 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 190 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 191 | func TestSet(t *testing.T){ |
| 192 | var pairs []interface{} |
| 193 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 194 | sdlInstanceMockTest.On("Set", []interface{}{pairs}).Return(nil) |
| 195 | err := sdlInstanceMockTest.Set(pairs) |
| 196 | assert.Nil(t, err) |
| 197 | } |
| 198 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 199 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 200 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 201 | func TestSetIf(t *testing.T){ |
| 202 | var newData map[string]interface{} |
| 203 | var oldData map[string]interface{} |
| 204 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 205 | sdlInstanceMockTest.On("SetIf", "key", newData, oldData).Return(true, nil) |
| 206 | res, err := sdlInstanceMockTest.SetIf("key", newData, oldData) |
| 207 | assert.Nil(t, err) |
| 208 | assert.NotNil(t, res) |
| 209 | } |
| 210 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 211 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 212 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 213 | func TestGetAll(t *testing.T){ |
| 214 | var data []string |
| 215 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 216 | sdlInstanceMockTest.On("GetAll").Return(data, nil) |
| 217 | res, err := sdlInstanceMockTest.GetAll() |
| 218 | assert.Nil(t, err) |
| 219 | assert.Nil(t, res) |
| 220 | } |
| 221 | |
Timo Tietavainen | e9fee6f | 2021-09-16 15:21:47 +0300 | [diff] [blame] | 222 | //Deprecated: Will be removed in a future release and tests in sdlSyncStorageMock_test.go |
| 223 | //should be used instead. |
dhirajverma | 54d6fb2 | 2021-06-15 09:33:25 +0300 | [diff] [blame] | 224 | func TestSetIfNotExistsAndPublish(t *testing.T){ |
| 225 | var data map[string]interface{} |
| 226 | var channelsAndEvents []string |
| 227 | sdlInstanceMockTest := initSdlInstanceMockTest() |
| 228 | sdlInstanceMockTest.On("SetIfNotExistsAndPublish", channelsAndEvents, "key", data).Return(true, nil) |
| 229 | res, err := sdlInstanceMockTest.SetIfNotExistsAndPublish(channelsAndEvents, "key", data) |
| 230 | assert.Nil(t, err) |
| 231 | assert.NotNil(t, res) |
| 232 | } |