package com.red.circle.live.adapter.app;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
import com.red.circle.live.app.dto.clientobject.LiveMicrophoneCO;
import com.red.circle.live.app.dto.cmd.MicBlockCmd;
import com.red.circle.live.app.dto.cmd.MicKillCmd;
import com.red.circle.live.app.dto.cmd.MicLockCmd;
import com.red.circle.live.app.dto.cmd.MicMuteCmd;
import com.red.circle.live.app.dto.cmd.MicUpDownCmd;
import com.red.circle.live.app.service.LiveMicrophoneService;
import java.util.Collections;
import java.util.List;
import org.junit.Test;

public class LiveMicRestControllerTest {

  @Test
  public void goDownShouldReturnTrueAfterServiceCall() {
    MicUpDownCmd cmd = new MicUpDownCmd();
    RecordingLiveMicrophoneService service = new RecordingLiveMicrophoneService();
    LiveMicRestController controller = new LiveMicRestController(service, null);

    Boolean result = controller.goDown(cmd);

    assertTrue(result);
    assertEquals(1, service.goDownCallCount);
    assertSame(cmd, service.lastGoDownCmd);
  }

  private static class RecordingLiveMicrophoneService implements LiveMicrophoneService {

    private int goDownCallCount;
    private MicUpDownCmd lastGoDownCmd;

    @Override
    public LiveMicrophoneCO goUp(MicUpDownCmd cmd) {
      return null;
    }

    @Override
    public void goDown(MicUpDownCmd cmd) {
      goDownCallCount++;
      lastGoDownCmd = cmd;
    }

    @Override
    public List<LiveMicrophoneCO> listMic(AppRoomIdCmd cmd) {
      return Collections.emptyList();
    }

    @Override
    public void lock(MicLockCmd cmd) {
    }

    @Override
    public void mute(MicMuteCmd cmd) {
    }

    @Override
    public void kill(MicKillCmd cmd) {
    }

    @Override
    public void init(AppRoomIdCmd cmd) {
    }

    @Override
    public void bannedLiveUser(String account) {
    }

    @Override
    public void bannedLiveUser(MicBlockCmd cmd) {
    }
  }
}
