package com.red.circle.other.app.inner.service.live.impl;

import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.red.circle.other.app.inner.convertor.live.RoomProfileInnerConvertor;
import com.red.circle.other.infra.database.cache.service.other.RoomManagerCacheService;
import com.red.circle.other.infra.database.mongo.entity.live.RoomProfileManager;
import com.red.circle.other.infra.database.mongo.service.live.RoomProfileManagerService;
import com.red.circle.other.inner.model.dto.live.RoomProfileManagerDTO;
import org.junit.jupiter.api.Test;

class RoomManagerClientServiceImplTest {

  @Test
  void getRoomProfileManagerByRoomAccountShouldConvertProfile() {
    RoomManagerCacheService roomManagerCacheService = mock(RoomManagerCacheService.class);
    RoomProfileInnerConvertor roomProfileInnerConvertor = mock(RoomProfileInnerConvertor.class);
    RoomProfileManagerService roomProfileManagerService = mock(RoomProfileManagerService.class);

    RoomManagerClientServiceImpl service = new RoomManagerClientServiceImpl(
        roomManagerCacheService,
        roomProfileInnerConvertor,
        roomProfileManagerService
    );

    RoomProfileManager roomProfileManager = new RoomProfileManager();
    RoomProfileManagerDTO roomProfileManagerDTO = new RoomProfileManagerDTO();

    when(roomProfileManagerService.getByRoomAccount("1001417")).thenReturn(roomProfileManager);
    when(roomProfileInnerConvertor.toRoomProfileManagerDTO(roomProfileManager))
        .thenReturn(roomProfileManagerDTO);

    RoomProfileManagerDTO result = service.getRoomProfileManagerByRoomAccount("1001417");

    assertSame(roomProfileManagerDTO, result);
    verify(roomProfileManagerService).getByRoomAccount("1001417");
    verify(roomProfileInnerConvertor).toRoomProfileManagerDTO(roomProfileManager);
  }
}
