@@ -102,42 +102,42 @@ public async Task GenerateApiTemplates_ProperlyLaysTheInformation()
102
102
103
103
// assert
104
104
File . Exists ( Path . Combine ( currentTestDirectory , apiTemplate . TypedResources . FileName ) ) . Should ( ) . BeTrue ( ) ;
105
- Directory . GetFiles ( Path . Combine ( currentTestDirectory , PolicyExtractor . PoliciesDirectoryName ) ) . Count ( ) . Should ( ) . Be ( 4 ) ;
105
+ Directory . GetFiles ( Path . Combine ( currentTestDirectory , PolicyExtractor . PoliciesDirectoryName ) ) . Count ( ) . Should ( ) . Be ( 6 ) ;
106
106
107
107
apiTemplate . Parameters . Should ( ) . NotBeNull ( ) ;
108
108
apiTemplate . Parameters . Should ( ) . ContainKey ( ParameterNames . ApimServiceName ) ;
109
109
apiTemplate . Parameters . Should ( ) . ContainKey ( ParameterNames . ServiceUrl ) ;
110
110
apiTemplate . Parameters . Should ( ) . ContainKey ( ParameterNames . ApiLoggerId ) ;
111
111
apiTemplate . Parameters . Should ( ) . ContainKey ( ParameterNames . PolicyXMLBaseUrl ) ;
112
112
apiTemplate . Parameters . Should ( ) . ContainKey ( ParameterNames . PolicyXMLSasToken ) ;
113
- apiTemplate . Resources . Count ( ) . Should ( ) . Be ( 23 ) ;
113
+ apiTemplate . Resources . Count ( ) . Should ( ) . Be ( 33 ) ;
114
114
115
115
// apis
116
- apiTemplate . TypedResources . Apis . Count ( ) . Should ( ) . Be ( 2 ) ;
116
+ apiTemplate . TypedResources . Apis . Count ( ) . Should ( ) . Be ( 3 ) ;
117
117
apiTemplate . TypedResources . Apis . All ( x => x . Type == ResourceTypeConstants . API ) . Should ( ) . BeTrue ( ) ;
118
118
apiTemplate . TypedResources . Apis . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
119
119
120
120
// api schemas
121
- apiTemplate . TypedResources . ApiSchemas . Count ( ) . Should ( ) . Be ( 2 ) ;
121
+ apiTemplate . TypedResources . ApiSchemas . Count ( ) . Should ( ) . Be ( 3 ) ;
122
122
apiTemplate . TypedResources . ApiSchemas . All ( x => x . Type == ResourceTypeConstants . APISchema ) . Should ( ) . BeTrue ( ) ;
123
123
apiTemplate . TypedResources . ApiSchemas . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
124
124
125
125
// diagnostics
126
- apiTemplate . TypedResources . Diagnostics . Count ( ) . Should ( ) . Be ( 3 ) ;
126
+ apiTemplate . TypedResources . Diagnostics . Count ( ) . Should ( ) . Be ( 4 ) ;
127
127
apiTemplate . TypedResources . Diagnostics . All ( x => x . Type == ResourceTypeConstants . APIServiceDiagnostic || x . Type == ResourceTypeConstants . APIDiagnostic ) . Should ( ) . BeTrue ( ) ;
128
128
apiTemplate . TypedResources . Diagnostics . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
129
129
130
130
// tags
131
- apiTemplate . TypedResources . Tags . Count ( ) . Should ( ) . Be ( 4 ) ;
132
- apiTemplate . TypedResources . Tags . All ( x => x . Type == ResourceTypeConstants . ProductTag ) . Should ( ) . BeTrue ( ) ;
131
+ apiTemplate . TypedResources . Tags . Count ( ) . Should ( ) . Be ( 6 ) ;
132
+ apiTemplate . TypedResources . Tags . All ( x => x . Type == ResourceTypeConstants . APITag ) . Should ( ) . BeTrue ( ) ;
133
133
134
134
// api products
135
- apiTemplate . TypedResources . ApiProducts . Count ( ) . Should ( ) . Be ( 2 ) ;
135
+ apiTemplate . TypedResources . ApiProducts . Count ( ) . Should ( ) . Be ( 3 ) ;
136
136
apiTemplate . TypedResources . ApiProducts . All ( x => x . Type == ResourceTypeConstants . ProductApi ) . Should ( ) . BeTrue ( ) ;
137
137
apiTemplate . TypedResources . ApiProducts . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
138
138
139
139
// api policies
140
- apiTemplate . TypedResources . ApiPolicies . Count ( ) . Should ( ) . Be ( 2 ) ;
140
+ apiTemplate . TypedResources . ApiPolicies . Count ( ) . Should ( ) . Be ( 3 ) ;
141
141
apiTemplate . TypedResources . ApiPolicies . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
142
142
143
143
// api operations
@@ -152,12 +152,12 @@ public async Task GenerateApiTemplates_ProperlyLaysTheInformation()
152
152
apiTemplate . TypedResources . ApiOperations . All ( x => x . Properties . Request . Representations . All ( o => o . Examples . ContainsKey ( "default" ) ) ) . Should ( ) . BeTrue ( ) ;
153
153
154
154
// api operations policies
155
- apiTemplate . TypedResources . ApiOperationsPolicies . Count ( ) . Should ( ) . Be ( 2 ) ;
155
+ apiTemplate . TypedResources . ApiOperationsPolicies . Count ( ) . Should ( ) . Be ( 3 ) ;
156
156
apiTemplate . TypedResources . ApiOperations . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
157
157
158
158
// api operations tags
159
- apiTemplate . TypedResources . ApiOperationsPolicies . Count ( ) . Should ( ) . Be ( 2 ) ;
160
- apiTemplate . TypedResources . ApiOperations . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
159
+ apiTemplate . TypedResources . ApiOperationsTags . Count ( ) . Should ( ) . Be ( 6 ) ;
160
+ apiTemplate . TypedResources . ApiOperationsTags . All ( x => x . Type == ResourceTypeConstants . APIOperationTag ) . Should ( ) . BeTrue ( ) ;
161
161
}
162
162
163
163
[ Fact ]
@@ -227,11 +227,76 @@ public async Task GenerateGraphQLApiTemplates()
227
227
string schemaContentType = "application/vnd.ms-azure-apim.graphql.schema" ;
228
228
229
229
// api schemas
230
- apiTemplate . TypedResources . ApiSchemas . Count ( ) . Should ( ) . Be ( 2 ) ;
230
+ apiTemplate . TypedResources . ApiSchemas . Count ( ) . Should ( ) . Be ( 3 ) ;
231
231
apiTemplate . TypedResources . ApiSchemas . All ( x => x . Type == ResourceTypeConstants . APISchema ) . Should ( ) . BeTrue ( ) ;
232
232
apiTemplate . TypedResources . ApiSchemas . All ( x => x . Properties is not null ) . Should ( ) . BeTrue ( ) ;
233
233
apiTemplate . TypedResources . ApiSchemas . All ( x => x . Properties . Document . Value . ToString ( ) . Equals ( fileReadingTask . Result . ToString ( ) ) ) . Should ( ) . BeTrue ( ) ;
234
234
apiTemplate . TypedResources . ApiSchemas . All ( x => x . Properties . ContentType . Equals ( schemaContentType ) ) . Should ( ) . BeTrue ( ) ;
235
235
}
236
+
237
+ [ Fact ]
238
+ public async Task GenerateApiTemplateAsync_WebsocketApiTypeOperationsNotGenerated ( )
239
+ {
240
+ // arrange
241
+ var currentTestDirectory = Path . Combine ( this . OutputDirectory , nameof ( GenerateApiTemplateAsync_WebsocketApiTypeOperationsNotGenerated ) ) ;
242
+
243
+ var extractorConfig = this . GetDefaultExtractorConsoleAppConfiguration (
244
+ sourceApimName : string . Empty ,
245
+ destinationApimName : string . Empty ,
246
+ resourceGroup : string . Empty ,
247
+ fileFolder : string . Empty ,
248
+ apiName : string . Empty ) ;
249
+ var extractorParameters = new ExtractorParameters ( extractorConfig ) ;
250
+
251
+ // mocked clients
252
+ var mockedApiClient = MockApisClient . GetMockedApiClientWithDefaultValues ( ) ;
253
+ var mockedProductClient = MockProductsClient . GetMockedApiClientWithDefaultValues ( ) ;
254
+ var mockedApiSchemaClient = MockApiSchemaClient . GetMockedApiClientWithGraphQLSchemaValues ( ) ;
255
+ var mockedPolicyClient = MockPolicyClient . GetMockedApiClientWithDefaultValues ( ) ;
256
+ var mockedTagClient = MockTagClient . GetMockedApiClientWithDefaultValues ( ) ;
257
+ var mockedApiOperationClient = MockApiOperationClient . GetMockedApiClientWithDefaultValues ( ) ;
258
+ var mockedDiagnosticClient = MockDiagnosticClient . GetMockedClientWithApiDependentValues ( ) ;
259
+ var mockedRevisionClient = MockApisRevisionsClient . GetMockedApiRevisionClientWithDefaultValues ( ) ;
260
+
261
+ // mocked extractors
262
+ var mockedDiagnosticExtractor = new DiagnosticExtractor ( this . GetTestLogger < DiagnosticExtractor > ( ) , mockedDiagnosticClient ) ;
263
+ var mockedApiSchemaExtractor = new ApiSchemaExtractor ( this . GetTestLogger < ApiSchemaExtractor > ( ) , mockedApiSchemaClient ) ;
264
+ var mockedPolicyExtractor = new PolicyExtractor ( this . GetTestLogger < PolicyExtractor > ( ) , mockedPolicyClient , new TemplateBuilder ( ) ) ;
265
+ var mockedProductApisExtractor = new ProductApisExtractor ( this . GetTestLogger < ProductApisExtractor > ( ) , mockedProductClient , mockedApiClient , new TemplateBuilder ( ) ) ;
266
+ var mockedTagExtractor = new TagExtractor ( this . GetTestLogger < TagExtractor > ( ) , mockedTagClient , new TemplateBuilder ( ) ) ;
267
+ var mockedApiOperationExtractor = new ApiOperationExtractor ( this . GetTestLogger < ApiOperationExtractor > ( ) , mockedApiOperationClient ) ;
268
+
269
+ var apiExtractor = new ApiExtractor (
270
+ this . GetTestLogger < ApiExtractor > ( ) ,
271
+ new TemplateBuilder ( ) ,
272
+ mockedApiClient ,
273
+ mockedDiagnosticExtractor ,
274
+ mockedApiSchemaExtractor ,
275
+ mockedPolicyExtractor ,
276
+ mockedProductApisExtractor ,
277
+ mockedTagExtractor ,
278
+ mockedApiOperationExtractor ,
279
+ mockedRevisionClient ) ;
280
+
281
+ var extractorExecutor = ExtractorExecutor . BuildExtractorExecutor (
282
+ this . GetTestLogger < ExtractorExecutor > ( ) ,
283
+ apiExtractor : apiExtractor ) ;
284
+ extractorExecutor . SetExtractorParameters ( extractorParameters ) ;
285
+
286
+ // act
287
+ var apiTemplate = await extractorExecutor . GenerateApiTemplateAsync (
288
+ singleApiName : It . IsAny < string > ( ) ,
289
+ multipleApiNames : It . IsAny < List < string > > ( ) ,
290
+ currentTestDirectory ) ;
291
+
292
+ // assert
293
+ File . Exists ( Path . Combine ( currentTestDirectory , apiTemplate . TypedResources . FileName ) ) . Should ( ) . BeTrue ( ) ;
294
+
295
+ // api operation resources
296
+ apiTemplate . TypedResources . ApiOperations . Count ( ) . Should ( ) . Be ( 2 ) ;
297
+ apiTemplate . TypedResources . ApiOperations . Any ( x => x . Name . Contains ( "websocket-api" ) ) . Should ( ) . BeFalse ( ) ;
298
+ apiTemplate . TypedResources . ApiOperationsTags . Count ( ) . Should ( ) . Be ( 6 ) ;
299
+ apiTemplate . TypedResources . ApiOperationsPolicies . Count ( ) . Should ( ) . Be ( 3 ) ;
300
+ }
236
301
}
237
302
}
0 commit comments