|
15 | 15 | */ |
16 | 16 | package io.gravitee.rest.api.management.v2.rest.mapper; |
17 | 17 |
|
18 | | -<<<<<<< HEAD |
19 | 18 | import static org.assertj.core.api.AssertionsForClassTypes.assertThat; |
20 | 19 | import static org.mockito.Mockito.mock; |
21 | 20 | import static org.mockito.Mockito.when; |
@@ -82,83 +81,6 @@ void shouldUseCorsMappperForHttpListener() { |
82 | 81 | assertThat(result.getCors().getExposeHeaders()).isEqualTo(expectedCors.getExposeHeaders()); |
83 | 82 | assertThat(result.getCors().getMaxAge()).isEqualTo(expectedCors.getMaxAge()); |
84 | 83 | assertThat(result.getCors().getRunPolicies()).isEqualTo(expectedCors.getRunPolicies()); |
85 | | -======= |
86 | | -import static org.assertj.core.api.Assertions.assertThat; |
87 | | - |
88 | | -import io.gravitee.apim.core.api.model.import_definition.ImportDefinition; |
89 | | -import io.gravitee.apim.core.membership.model.PrimaryOwnerEntity; |
90 | | -import io.gravitee.rest.api.management.v2.rest.model.ApiV4; |
91 | | -import io.gravitee.rest.api.management.v2.rest.model.ExportApiV4; |
92 | | -import io.gravitee.rest.api.management.v2.rest.model.MembershipMemberType; |
93 | | -import io.gravitee.rest.api.management.v2.rest.model.PrimaryOwner; |
94 | | -import org.junit.jupiter.api.DisplayNameGeneration; |
95 | | -import org.junit.jupiter.api.DisplayNameGenerator; |
96 | | -import org.junit.jupiter.api.Test; |
97 | | - |
98 | | -@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) |
99 | | -class ImportExportApiMapperTest { |
100 | | - |
101 | | - @Test |
102 | | - void should_map_primary_owner_and_media_fields() { |
103 | | - // Given |
104 | | - var po = new PrimaryOwner().id("po-id").email("po@gravitee.io").displayName("John Doe").type(MembershipMemberType.USER); |
105 | | - |
106 | | - var api = new ApiV4(); |
107 | | - api.setPrimaryOwner(po); |
108 | | - |
109 | | - var exportApiV4 = new ExportApiV4(); |
110 | | - exportApiV4.setApi(api); |
111 | | - exportApiV4.setApiPicture("picture-bytes"); |
112 | | - exportApiV4.setApiBackground("bg-bytes"); |
113 | | - |
114 | | - // When |
115 | | - ImportDefinition importDefinition = ImportExportApiMapper.INSTANCE.toImportDefinition(exportApiV4); |
116 | | - |
117 | | - // Then |
118 | | - var apiExport = importDefinition.getApiExport(); |
119 | | - assertThat(apiExport).isNotNull(); |
120 | | - assertThat(apiExport.getPicture()).isEqualTo("picture-bytes"); |
121 | | - assertThat(apiExport.getBackground()).isEqualTo("bg-bytes"); |
122 | | - assertThat(apiExport.getPrimaryOwner()).isNotNull(); |
123 | | - assertThat(apiExport.getPrimaryOwner().id()).isEqualTo("po-id"); |
124 | | - assertThat(apiExport.getPrimaryOwner().email()).isEqualTo("po@gravitee.io"); |
125 | | - assertThat(apiExport.getPrimaryOwner().displayName()).isEqualTo("John Doe"); |
126 | | - assertThat(apiExport.getPrimaryOwner().type()).isEqualTo(PrimaryOwnerEntity.Type.USER); |
127 | | - } |
128 | | - |
129 | | - @Test |
130 | | - void should_default_primary_owner_type_to_user_when_null() { |
131 | | - // Given |
132 | | - var po = new PrimaryOwner().id("po-id").email("po@gravitee.io").displayName("John Doe"); // no type set |
133 | | - |
134 | | - var api = new ApiV4(); |
135 | | - api.setPrimaryOwner(po); |
136 | | - |
137 | | - var exportApiV4 = new ExportApiV4(); |
138 | | - exportApiV4.setApi(api); |
139 | | - |
140 | | - // When |
141 | | - var importDefinition = ImportExportApiMapper.INSTANCE.toImportDefinition(exportApiV4); |
142 | | - |
143 | | - // Then |
144 | | - assertThat(importDefinition.getApiExport().getPrimaryOwner()).isNotNull(); |
145 | | - assertThat(importDefinition.getApiExport().getPrimaryOwner().type()).isEqualTo(PrimaryOwnerEntity.Type.USER); |
146 | | - } |
147 | | - |
148 | | - @Test |
149 | | - void should_not_set_primary_owner_when_absent() { |
150 | | - // Given |
151 | | - var api = new ApiV4(); |
152 | | - // no primary owner |
153 | | - var exportApiV4 = new ExportApiV4(); |
154 | | - exportApiV4.setApi(api); |
155 | | - |
156 | | - // When |
157 | | - var importDefinition = ImportExportApiMapper.INSTANCE.toImportDefinition(exportApiV4); |
158 | | - |
159 | | - // Then |
160 | | - assertThat(importDefinition.getApiExport().getPrimaryOwner()).isNull(); |
161 | | ->>>>>>> 5832b9666c (fix: set primary owner for v4 api export) |
162 | 84 | } |
163 | 85 |
|
164 | 86 | @Test |
|
0 commit comments