1 /*
2  * Copyright 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.appfunctions.metadata
18 
19 import androidx.appfunctions.metadata.AppFunctionPrimitiveTypeMetadata.Companion.TYPE_INT
20 import com.google.common.truth.Truth.assertThat
21 import org.junit.Test
22 
23 class AppFunctionResponseMetadataTest {
24 
25     @Test
appFunctionResponseMetadata_toAppFunctionResponseMetadataDocument_returnsCorrectDocumentnull26     fun appFunctionResponseMetadata_toAppFunctionResponseMetadataDocument_returnsCorrectDocument() {
27         val responseMetadata =
28             AppFunctionResponseMetadata(
29                 valueType =
30                     AppFunctionPrimitiveTypeMetadata(
31                         type = TYPE_INT,
32                         isNullable = false,
33                     )
34             )
35 
36         val responseMetadataDocument = responseMetadata.toAppFunctionResponseMetadataDocument()
37 
38         assertThat(responseMetadataDocument)
39             .isEqualTo(
40                 AppFunctionResponseMetadataDocument(
41                     valueType =
42                         AppFunctionDataTypeMetadataDocument(
43                             type = TYPE_INT,
44                             isNullable = false,
45                         )
46                 )
47             )
48     }
49 
50     @Test
appFunctionResponseMetadataDocument_toAppFunctionResponseMetadata_returnsCorrectMetadatanull51     fun appFunctionResponseMetadataDocument_toAppFunctionResponseMetadata_returnsCorrectMetadata() {
52         val responseMetadataDocument =
53             AppFunctionResponseMetadataDocument(
54                 valueType =
55                     AppFunctionDataTypeMetadataDocument(
56                         type = TYPE_INT,
57                         isNullable = false,
58                     )
59             )
60 
61         val responseMetadata = responseMetadataDocument.toAppFunctionResponseMetadata()
62 
63         assertThat(responseMetadata)
64             .isEqualTo(
65                 AppFunctionResponseMetadata(
66                     valueType =
67                         AppFunctionPrimitiveTypeMetadata(
68                             type = TYPE_INT,
69                             isNullable = false,
70                         )
71                 )
72             )
73     }
74 }
75