package io.wdd.server.pusher;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.wdd.pusher.MessagePusher;
import io.wdd.pusher.beans.*;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

@SpringBootTest
public class PusherTest {

    @Resource
    MessagePusher messagePusher;

    @Resource
    ObjectMapper objectMapper;

    @Test
    public void test() {

        NtfySendMessage ntfySendMessage = NtfySendMessage.builder()
                .title("来自Java的测试内容")
                .priority(1)
                .message("Hello World")
                .build();

        CmiiUpdateMessage build = CmiiUpdateMessage.builder().appName("cmii-uav-gateway").namespace("uavcloud-dev").fromTag("1.0.0").toTag("5.0.0").replicas("1").deployStatus(Boolean.TRUE).build();

        System.out.println("ntfySendMessage = " + ntfySendMessage);


        NtfyReceiveMessage ntfyReceiveMessage = messagePusher.Send(build, PushMessageType.CMII_UPDATE);

        System.out.println("ntfyReceiveMessage = " + ntfyReceiveMessage);

    }

    @SneakyThrows
    @Test
    public void testImageSyncMessage() {

        ImageSyncMessage imageSyncMessage = new ImageSyncMessage();

        String s = objectMapper.writeValueAsString(imageSyncMessage);

        System.out.println("imageSyncMessage = " + s);
    }
}
