1 package com.oransc.rappmanager.models.cache;
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;
7 import com.oransc.rappmanager.models.rapp.Rapp;
9 import org.junit.jupiter.api.Test;
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.boot.test.context.SpringBootTest;
13 @SpringBootTest(classes = {BeanTestConfiguration.class, RappCacheService.class})
14 class RappCacheServiceTest {
17 RappCacheService rappCacheService;
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);
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);
40 void testGetRappsEmpty() {
41 assertNotNull(rappCacheService.getAllRapp());
42 assertThat(rappCacheService.getAllRapp()).isEmpty();
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();