@@ -5,6 +5,7 @@ package com.imagekit.api.models.webhooks
55import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
66import com.imagekit.api.core.JsonValue
77import com.imagekit.api.core.jsonMapper
8+ import com.imagekit.api.models.files.File
89import java.time.OffsetDateTime
910import org.assertj.core.api.Assertions.assertThat
1011import org.junit.jupiter.api.Test
@@ -18,15 +19,143 @@ internal class DamFileVersionCreateEventTest {
1819 .id(" id" )
1920 .type(" file-version.created" )
2021 .createdAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
21- .data(JsonValue .from(mapOf<String , Any >()))
22+ .data(
23+ File .builder()
24+ .addAiTag(
25+ File .AiTag .builder()
26+ .confidence(0.0 )
27+ .name(" name" )
28+ .source(" source" )
29+ .build()
30+ )
31+ .audioCodec(" audioCodec" )
32+ .bitRate(0L )
33+ .createdAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
34+ .customCoordinates(" customCoordinates" )
35+ .customMetadata(
36+ File .CustomMetadata .builder()
37+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
38+ .build()
39+ )
40+ .description(" description" )
41+ .duration(0L )
42+ .embeddedMetadata(
43+ File .EmbeddedMetadata .builder()
44+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
45+ .build()
46+ )
47+ .fileId(" fileId" )
48+ .filePath(" filePath" )
49+ .fileType(" fileType" )
50+ .hasAlpha(true )
51+ .height(0.0 )
52+ .isPrivateFile(true )
53+ .isPublished(true )
54+ .mime(" mime" )
55+ .name(" name" )
56+ .selectedFieldsSchema(
57+ File .SelectedFieldsSchema .builder()
58+ .putAdditionalProperty(
59+ " foo" ,
60+ JsonValue .from(
61+ mapOf (
62+ " type" to " Text" ,
63+ " defaultValue" to " string" ,
64+ " isValueRequired" to true ,
65+ " maxLength" to 0 ,
66+ " maxValue" to " string" ,
67+ " minLength" to 0 ,
68+ " minValue" to " string" ,
69+ " readOnly" to true ,
70+ " selectOptions" to
71+ listOf (" small" , " medium" , " large" , 30 , 40 , true ),
72+ " selectOptionsTruncated" to true ,
73+ )
74+ ),
75+ )
76+ .build()
77+ )
78+ .size(0.0 )
79+ .addTag(" string" )
80+ .thumbnail(" https://example.com" )
81+ .type(File .Type .FILE )
82+ .updatedAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
83+ .url(" https://example.com" )
84+ .versionInfo(File .VersionInfo .builder().id(" id" ).name(" name" ).build())
85+ .videoCodec(" videoCodec" )
86+ .width(0.0 )
87+ .build()
88+ )
2289 .build()
2390
2491 assertThat(damFileVersionCreateEvent.id()).isEqualTo(" id" )
2592 assertThat(damFileVersionCreateEvent.type()).isEqualTo(" file-version.created" )
2693 assertThat(damFileVersionCreateEvent.createdAt())
2794 .isEqualTo(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
28- assertThat(damFileVersionCreateEvent._data ())
29- .isEqualTo(JsonValue .from(mapOf<String , Any >()))
95+ assertThat(damFileVersionCreateEvent.data())
96+ .isEqualTo(
97+ File .builder()
98+ .addAiTag(
99+ File .AiTag .builder().confidence(0.0 ).name(" name" ).source(" source" ).build()
100+ )
101+ .audioCodec(" audioCodec" )
102+ .bitRate(0L )
103+ .createdAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
104+ .customCoordinates(" customCoordinates" )
105+ .customMetadata(
106+ File .CustomMetadata .builder()
107+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
108+ .build()
109+ )
110+ .description(" description" )
111+ .duration(0L )
112+ .embeddedMetadata(
113+ File .EmbeddedMetadata .builder()
114+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
115+ .build()
116+ )
117+ .fileId(" fileId" )
118+ .filePath(" filePath" )
119+ .fileType(" fileType" )
120+ .hasAlpha(true )
121+ .height(0.0 )
122+ .isPrivateFile(true )
123+ .isPublished(true )
124+ .mime(" mime" )
125+ .name(" name" )
126+ .selectedFieldsSchema(
127+ File .SelectedFieldsSchema .builder()
128+ .putAdditionalProperty(
129+ " foo" ,
130+ JsonValue .from(
131+ mapOf (
132+ " type" to " Text" ,
133+ " defaultValue" to " string" ,
134+ " isValueRequired" to true ,
135+ " maxLength" to 0 ,
136+ " maxValue" to " string" ,
137+ " minLength" to 0 ,
138+ " minValue" to " string" ,
139+ " readOnly" to true ,
140+ " selectOptions" to
141+ listOf (" small" , " medium" , " large" , 30 , 40 , true ),
142+ " selectOptionsTruncated" to true ,
143+ )
144+ ),
145+ )
146+ .build()
147+ )
148+ .size(0.0 )
149+ .addTag(" string" )
150+ .thumbnail(" https://example.com" )
151+ .type(File .Type .FILE )
152+ .updatedAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
153+ .url(" https://example.com" )
154+ .versionInfo(File .VersionInfo .builder().id(" id" ).name(" name" ).build())
155+ .videoCodec(" videoCodec" )
156+ .width(0.0 )
157+ .build()
158+ )
30159 }
31160
32161 @Test
@@ -37,7 +166,73 @@ internal class DamFileVersionCreateEventTest {
37166 .id(" id" )
38167 .type(" file-version.created" )
39168 .createdAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
40- .data(JsonValue .from(mapOf<String , Any >()))
169+ .data(
170+ File .builder()
171+ .addAiTag(
172+ File .AiTag .builder()
173+ .confidence(0.0 )
174+ .name(" name" )
175+ .source(" source" )
176+ .build()
177+ )
178+ .audioCodec(" audioCodec" )
179+ .bitRate(0L )
180+ .createdAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
181+ .customCoordinates(" customCoordinates" )
182+ .customMetadata(
183+ File .CustomMetadata .builder()
184+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
185+ .build()
186+ )
187+ .description(" description" )
188+ .duration(0L )
189+ .embeddedMetadata(
190+ File .EmbeddedMetadata .builder()
191+ .putAdditionalProperty(" foo" , JsonValue .from(" bar" ))
192+ .build()
193+ )
194+ .fileId(" fileId" )
195+ .filePath(" filePath" )
196+ .fileType(" fileType" )
197+ .hasAlpha(true )
198+ .height(0.0 )
199+ .isPrivateFile(true )
200+ .isPublished(true )
201+ .mime(" mime" )
202+ .name(" name" )
203+ .selectedFieldsSchema(
204+ File .SelectedFieldsSchema .builder()
205+ .putAdditionalProperty(
206+ " foo" ,
207+ JsonValue .from(
208+ mapOf (
209+ " type" to " Text" ,
210+ " defaultValue" to " string" ,
211+ " isValueRequired" to true ,
212+ " maxLength" to 0 ,
213+ " maxValue" to " string" ,
214+ " minLength" to 0 ,
215+ " minValue" to " string" ,
216+ " readOnly" to true ,
217+ " selectOptions" to
218+ listOf (" small" , " medium" , " large" , 30 , 40 , true ),
219+ " selectOptionsTruncated" to true ,
220+ )
221+ ),
222+ )
223+ .build()
224+ )
225+ .size(0.0 )
226+ .addTag(" string" )
227+ .thumbnail(" https://example.com" )
228+ .type(File .Type .FILE )
229+ .updatedAt(OffsetDateTime .parse(" 2019-12-27T18:11:19.117Z" ))
230+ .url(" https://example.com" )
231+ .versionInfo(File .VersionInfo .builder().id(" id" ).name(" name" ).build())
232+ .videoCodec(" videoCodec" )
233+ .width(0.0 )
234+ .build()
235+ )
41236 .build()
42237
43238 val roundtrippedDamFileVersionCreateEvent =
0 commit comments