Skip to content

Commit

Permalink
port deployment template unit test from track1 (#10169)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Apr 14, 2020
1 parent 03035f9 commit 8f189cd
Showing 1 changed file with 38 additions and 0 deletions.
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;
}
}

0 comments on commit 8f189cd

Please sign in to comment.