package com.pgf.mqspring.component.impl; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; import java.io.ByteArrayInputStream; import java.io.IOException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.springframework.test.util.ReflectionTestUtils; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.model.S3Object; import com.pgf.mqspring.component.MqSpringMessageSourceComponent; import com.pgf.mqspring.constant.MqSpringMessageId; import com.pgf.mqspring.model.TelegramInfoModel; class TelegramInfoComponentImplTest03 { @Mock AmazonS3 s3Client; @Mock MqSpringMessageSourceComponent messageSource; TelegramInfoComponentImpl target; @BeforeEach void beforeEach() throws IOException { MockitoAnnotations.openMocks(this); S3Object s3Object = new S3Object(); s3Object.setObjectContent(new ByteArrayInputStream(new byte[0])); Mockito.when(s3Client.getObject(anyString(), anyString())).thenReturn(s3Object); target = new TelegramInfoComponentImpl(s3Client, messageSource, "", ""); } @Test void checkTelegramInfoModel01() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode(""); assertFalse(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); verify(messageSource, times(1)).getMessage(MqSpringMessageId.SYS7062E); } @Test void checkTelegramInfoModel02() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName(""); assertFalse(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); verify(messageSource, times(1)).getMessage(MqSpringMessageId.SYS7064E); } @Test void checkTelegramInfoModel03() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv(""); assertFalse(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); verify(messageSource, times(1)).getMessage(MqSpringMessageId.SYS7065E); } @Test void checkTelegramInfoModel04() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("9"); assertFalse(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); verify(messageSource, times(1)).getMessage(MqSpringMessageId.SYS7066E); } @Test void checkTelegramInfoModel05() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("0"); model.setRepeatNum(""); assertFalse(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); verify(messageSource, times(1)).getMessage(MqSpringMessageId.SYS7067E); } @Test void checkTelegramInfoModel06() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("0"); model.setRepeatNum("1"); model.setGroupNum(""); assertFalse(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); verify(messageSource, times(1)).getMessage(MqSpringMessageId.SYS7068E); } @Test void checkTelegramInfoModel07() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("0"); model.setRepeatNum("0"); model.setItemLength(""); assertFalse(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); verify(messageSource, times(1)).getMessage(MqSpringMessageId.SYS7069E); } @Test void checkTelegramInfoModel08() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("0"); model.setRepeatNum("0"); model.setItemLength("0"); assertTrue(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); } @Test void checkTelegramInfoModel09() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("1"); model.setRepeatNum("0"); model.setItemLength("0"); assertTrue(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); } @Test void checkTelegramInfoModel10() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("2"); model.setRepeatNum("0"); model.setItemLength("0"); assertTrue(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); } @Test void checkTelegramInfoModel11() { TelegramInfoModel model = new TelegramInfoModel(); model.setDispCode("0"); model.setItemName("0"); model.setCharDiv("0"); model.setRepeatNum("1"); model.setGroupNum("1"); model.setItemLength("0"); assertTrue(() -> ReflectionTestUtils.invokeMethod(target, "checkTelegramInfoModel", model)); } }