优化
This commit is contained in:
+14
@@ -59,4 +59,18 @@ class InternalMeasurementImageControllerTest {
|
||||
assertThat(response.getBody()).containsExactly(1, 2, 3);
|
||||
verify(images).download(11L, 21L, 41L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void storesAnUnmatchedMojiaReceiptImageWithoutAnInboundId() {
|
||||
var file = new MockMultipartFile("file", "mojia.jpg", MediaType.IMAGE_JPEG_VALUE,
|
||||
new byte[]{1, 2, 3});
|
||||
var result = new MeasurementImageService.UploadResult(41L, "mojia.jpg",
|
||||
MediaType.IMAGE_JPEG_VALUE, 3L, "NOT_REQUIRED", null, null, null, null, null);
|
||||
when(images.uploadMojiaReceiptEvidence(11L, 51L, 31L, file)).thenReturn(result);
|
||||
|
||||
var response = controller.uploadReceipt("internal-token", 31L, 11L, 51L, file);
|
||||
|
||||
assertThat(response.data().fileId()).isEqualTo(41L);
|
||||
verify(images).uploadMojiaReceiptEvidence(11L, 51L, 31L, file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockMultipartFile;
|
||||
@@ -70,6 +71,29 @@ class MeasurementImageServiceEvidenceTest {
|
||||
verifyNoInteractions(ocr);
|
||||
}
|
||||
|
||||
@Test
|
||||
void storesUnmatchedMojiaReceiptUnderItsOwnBusinessType() {
|
||||
var image = new MockMultipartFile("file", "mojia.jpg", MediaType.IMAGE_JPEG_VALUE,
|
||||
new byte[]{1, 2, 3});
|
||||
when(storage.store(11L, 51L, image)).thenReturn(new MeasurementImageStorage.Stored(
|
||||
"measurements/11/51/mojia.jpg", Path.of("mojia.jpg"), MediaType.IMAGE_JPEG_VALUE,
|
||||
3L, "hash", "mojia.jpg"));
|
||||
ArgumentCaptor<FileObjectEntity> object = ArgumentCaptor.forClass(FileObjectEntity.class);
|
||||
doAnswer(invocation -> {
|
||||
FileObjectEntity value = invocation.getArgument(0);
|
||||
value.setId(41L);
|
||||
return 1;
|
||||
}).when(files).insert(any(FileObjectEntity.class));
|
||||
|
||||
var result = service.uploadMojiaReceiptEvidence(11L, 51L, 31L, image);
|
||||
|
||||
assertThat(result.fileId()).isEqualTo(41L);
|
||||
verify(files).insert(object.capture());
|
||||
assertThat(object.getValue().getBusinessType()).isEqualTo("MOJIA_MEASUREMENT_RECEIPT");
|
||||
assertThat(object.getValue().getBusinessId()).isEqualTo("51");
|
||||
verifyNoInteractions(ocr);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldHandleCase02() {
|
||||
FileObjectEntity object = new FileObjectEntity();
|
||||
|
||||
Reference in New Issue
Block a user