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;
22 UUID rappId = UUID.randomUUID();
23 Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).build();
24 rappCacheService.putRapp(rapp);
25 assertNotNull(rappCacheService.getRapp(String.valueOf(rappId)).get());
26 assertEquals(rappCacheService.getRapp(String.valueOf(rappId)).get().getRappId(), rappId);
27 rappCacheService.deleteRapp(rapp);
32 UUID rappId = UUID.randomUUID();
33 Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).build();
34 rappCacheService.putRapp(rapp);
35 assertNotNull(rappCacheService.getAllRapp());
36 assertThat(rappCacheService.getAllRapp()).hasSize(1);
37 rappCacheService.deleteRapp(rapp);
41 void testGetRappsEmpty() {
42 assertNotNull(rappCacheService.getAllRapp());
43 assertThat(rappCacheService.getAllRapp()).isEmpty();
47 void testDeleteRapp() {
48 UUID rappId = UUID.randomUUID();
49 Rapp rapp = Rapp.builder().rappId(rappId).name(String.valueOf(rappId)).build();
50 rappCacheService.putRapp(rapp);
51 assertEquals(rappCacheService.getRapp(String.valueOf(rappId)).get().getRappId(), rappId);
52 rappCacheService.deleteRapp(rapp);
53 assertThat(rappCacheService.getRapp(String.valueOf(rappId))).isEmpty();