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 com.google.common.truth.Truth.assertThat
20 import org.junit.Test
21 
22 class AppFunctionSchemaMetadataTest {
23 
24     @Test
appFunctionSchemaMetadata_equalsAndHashCodenull25     fun appFunctionSchemaMetadata_equalsAndHashCode() {
26         val schema1 =
27             AppFunctionSchemaMetadata(category = "testCategory", name = "testName", version = 1L)
28         val schema2 =
29             AppFunctionSchemaMetadata(category = "testCategory", name = "testName", version = 1L)
30         val schema3 =
31             AppFunctionSchemaMetadata(
32                 category = "testCategory2", // Different category
33                 name = "testName",
34                 version = 1L
35             )
36         val schema4 =
37             AppFunctionSchemaMetadata(
38                 category = "testCategory",
39                 name = "testName2", // Different name
40                 version = 1L
41             )
42         val schema5 =
43             AppFunctionSchemaMetadata(
44                 category = "testCategory",
45                 name = "testName",
46                 version = 2L // Different version
47             )
48 
49         assertThat(schema1).isEqualTo(schema2)
50         assertThat(schema1.hashCode()).isEqualTo(schema2.hashCode())
51 
52         assertThat(schema1).isNotEqualTo(schema3)
53         assertThat(schema1.hashCode()).isNotEqualTo(schema3.hashCode())
54 
55         assertThat(schema1).isNotEqualTo(schema4)
56         assertThat(schema1.hashCode()).isNotEqualTo(schema4.hashCode())
57 
58         assertThat(schema1).isNotEqualTo(schema5)
59         assertThat(schema1.hashCode()).isNotEqualTo(schema5.hashCode())
60     }
61 }
62