forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
port deployment template unit test from track1 (#10169)
- Loading branch information
1 parent
03035f9
commit 8f189cd
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...t/src/test/java/com/azure/management/resources/implementation/TypeSerializationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.management.resources.implementation; | ||
|
||
import com.azure.core.management.serializer.AzureJacksonAdapter; | ||
import com.azure.core.util.serializer.SerializerEncoding; | ||
import com.azure.management.resources.DeploymentProperties; | ||
import com.azure.management.resources.models.DeploymentExtendedInner; | ||
import com.azure.management.resources.models.DeploymentInner; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TypeSerializationTests { | ||
|
||
@Test | ||
public void testDeploymentSerialization() throws Exception { | ||
final String templateJson = "{ \"/subscriptions/<redacted>/resourceGroups/<redacted>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<redacted>\": {} }"; | ||
|
||
DeploymentImpl deployment = new DeploymentImpl(new DeploymentExtendedInner(), "", null); | ||
deployment.withTemplate(templateJson); | ||
|
||
AzureJacksonAdapter serializerAdapter = new AzureJacksonAdapter(); | ||
String deploymentJson = serializerAdapter.serialize(createRequestFromInner(deployment), SerializerEncoding.JSON); | ||
Assertions.assertTrue(deploymentJson.contains("Microsoft.ManagedIdentity")); | ||
} | ||
|
||
private static DeploymentInner createRequestFromInner(DeploymentImpl deployment) { | ||
DeploymentInner inner = new DeploymentInner() | ||
.withProperties(new DeploymentProperties()); | ||
inner.properties().withMode(deployment.mode()); | ||
inner.properties().withTemplate(deployment.template()); | ||
inner.properties().withTemplateLink(deployment.templateLink()); | ||
inner.properties().withParameters(deployment.parameters()); | ||
inner.properties().withParametersLink(deployment.parametersLink()); | ||
return inner; | ||
} | ||
} |