Update flow and architecture images
[nonrtric/plt/rappmanager.git] / rapp-manager-models / src / test / java / com / oransc / rappmanager / models / cache / RappCacheServiceTest.java
1 package com.oransc.rappmanager.models.cache;
2
3 import static org.assertj.core.api.Assertions.assertThat;
4 import static org.junit.jupiter.api.Assertions.assertEquals;
5 import static org.junit.jupiter.api.Assertions.assertNotNull;
6
7 import com.oransc.rappmanager.models.rapp.Rapp;
8 import java.util.UUID;
9 import org.junit.jupiter.api.Test;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.boot.test.context.SpringBootTest;
12
13 @SpringBootTest(classes = {BeanTestConfiguration.class, RappCacheService.class})
14 class RappCacheServiceTest {
15
16     @Autowired
17     RappCacheService rappCacheService;
18
19     @Test
20     void testPutRapp() {
21         UUID rappId = UUID.randomUUID();
22         Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).build();
23         rappCacheService.putRapp(rapp);
24         assertNotNull(rappCacheService.getRapp(String.valueOf(rappId)).get());
25         assertEquals(rappCacheService.getRapp(String.valueOf(rappId)).get().getRappId(), rappId);
26         rappCacheService.deleteRapp(rapp);
27     }
28
29     @Test
30     void testGetRapps() {
31         UUID rappId = UUID.randomUUID();
32         Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).build();
33         rappCacheService.putRapp(rapp);
34         assertNotNull(rappCacheService.getAllRapp());
35         assertThat(rappCacheService.getAllRapp()).hasSize(1);
36         rappCacheService.deleteRapp(rapp);
37     }
38
39     @Test
40     void testGetRappsEmpty() {
41         assertNotNull(rappCacheService.getAllRapp());
42         assertThat(rappCacheService.getAllRapp()).isEmpty();
43     }
44
45     @Test
46     void testDeleteRapp() {
47         UUID rappId = UUID.randomUUID();
48         Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).build();
49         rappCacheService.putRapp(rapp);
50         assertEquals(rappCacheService.getRapp(String.valueOf(rappId)).get().getRappId(), rappId);
51         rappCacheService.deleteRapp(rapp);
52         assertThat(rappCacheService.getRapp(String.valueOf(rappId))).isEmpty();
53     }
54 }