diff --git a/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/ExampleParser.java b/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/ExampleParser.java index e05efc28e6..c374eaa623 100644 --- a/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/ExampleParser.java +++ b/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/ExampleParser.java @@ -162,7 +162,7 @@ private static List parseMethod(FluentResourceCol List ret = null; ClientMethod clientMethod = collectionMethod.getInnerClientMethod(); - if (FluentUtils.validToGenerateExample(clientMethod)) { + if (FluentUtils.validRequestContentTypeToGenerateExample(clientMethod)) { ret = new ArrayList<>(); List methodParameters = getParameters(clientMethod); @@ -180,7 +180,7 @@ private static List parseMethod(FluentResourceCol private static List parseMethod(MethodGroupClient methodGroup, ClientMethod clientMethod) { List ret = null; - if (FluentUtils.validToGenerateExample(clientMethod)) { + if (FluentUtils.validRequestContentTypeToGenerateExample(clientMethod)) { ret = new ArrayList<>(); List methodParameters = getParameters(clientMethod); @@ -245,7 +245,7 @@ private static List parseResourceCreate(FluentResou List collectionMethods = resourceCreate.getMethodReferences(); for (FluentCollectionMethod collectionMethod : collectionMethods) { ClientMethod clientMethod = collectionMethod.getInnerClientMethod(); - if (FluentUtils.validToGenerateExample(clientMethod)) { + if (FluentUtils.validRequestContentTypeToGenerateExample(clientMethod)) { if (ret == null) { ret = new ArrayList<>(); } @@ -361,7 +361,7 @@ private static List parseResourceUpdate(FluentResou List collectionMethods = resourceUpdate.getMethodReferences(); for (FluentCollectionMethod collectionMethod : collectionMethods) { ClientMethod clientMethod = collectionMethod.getInnerClientMethod(); - if (FluentUtils.validToGenerateExample(clientMethod)) { + if (FluentUtils.validRequestContentTypeToGenerateExample(clientMethod)) { if (ret == null) { ret = new ArrayList<>(); } diff --git a/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/MockUnitTestParser.java b/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/MockUnitTestParser.java index 5b66157b27..a24a34a3fd 100644 --- a/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/MockUnitTestParser.java +++ b/fluentgen/src/main/java/com/azure/autorest/fluent/mapper/MockUnitTestParser.java @@ -62,7 +62,7 @@ private static FluentMethodMockUnitTest parseResourceCreate(FluentResourceCollec List collectionMethods = resourceCreate.getMethodReferences(); for (FluentCollectionMethod collectionMethod : collectionMethods) { ClientMethod clientMethod = collectionMethod.getInnerClientMethod(); - if (FluentUtils.validToGenerateExample(clientMethod) && requiresExample(clientMethod)) { + if (FluentUtils.validRequestContentTypeToGenerateExample(clientMethod) && FluentUtils.validResponseContentTypeToGenerateExample(clientMethod) && requiresExample(clientMethod)) { List methodParameters = getParameters(clientMethod); MethodParameter requestBodyParameter = findRequestBodyParameter(methodParameters); ProxyMethodExample proxyMethodExample = createProxyMethodExample(clientMethod, methodParameters); @@ -71,6 +71,7 @@ private static FluentMethodMockUnitTest parseResourceCreate(FluentResourceCollec ResponseInfo responseInfo = createProxyMethodExampleResponse(clientMethod); unitTest = new FluentMethodMockUnitTest(resourceCreateExample, collection, collectionMethod, + FluentUtils.isResponseType(collectionMethod.getFluentReturnType()) ? FluentUtils.getValueTypeFromResponseType(collectionMethod.getFluentReturnType()) : collectionMethod.getFluentReturnType(), responseInfo.responseExample, responseInfo.verificationObjectName, responseInfo.verificationNode); break; @@ -87,14 +88,14 @@ private static FluentMethodMockUnitTest parseMethod(FluentResourceCollection col try { ClientMethod clientMethod = collectionMethod.getInnerClientMethod(); - if (FluentUtils.validToGenerateExample(clientMethod) && requiresExample(clientMethod)) { + if (FluentUtils.validRequestContentTypeToGenerateExample(clientMethod) && FluentUtils.validResponseContentTypeToGenerateExample(clientMethod) && requiresExample(clientMethod)) { List methodParameters = getParameters(clientMethod); ProxyMethodExample proxyMethodExample = createProxyMethodExample(clientMethod, methodParameters); FluentCollectionMethodExample collectionMethodExample = parseMethodForExample(collection, collectionMethod, methodParameters, proxyMethodExample.getName(), proxyMethodExample); ResponseInfo responseInfo = createProxyMethodExampleResponse(clientMethod); - unitTest = new FluentMethodMockUnitTest(collectionMethodExample, collection, collectionMethod, + unitTest = new FluentMethodMockUnitTest(collectionMethodExample, collection, collectionMethod, collectionMethod.getFluentReturnType(), responseInfo.responseExample, responseInfo.verificationObjectName, responseInfo.verificationNode); } } catch (PossibleCredentialException e) { @@ -143,10 +144,17 @@ private static ResponseInfo createProxyMethodExampleResponse(ClientMethod client Object jsonObject; ExampleNode verificationNode; String verificationObjectName; + + IType clientReturnType = clientMethod.getReturnValue().getType(); + final boolean isResponseType = FluentUtils.isResponseType(clientReturnType); + if (isResponseType) { + clientReturnType = FluentUtils.getValueTypeFromResponseType(clientReturnType); + } + if (clientMethod.getType() == ClientMethodType.PagingSync) { // pageable - if (clientMethod.getReturnValue().getType() instanceof GenericType) { - IType elementType = ((GenericType) clientMethod.getReturnValue().getType()).getTypeArguments()[0]; + if (clientReturnType instanceof GenericType) { + IType elementType = ((GenericType) clientReturnType).getTypeArguments()[0]; Object firstJsonObjectInPageable = ModelTestCaseUtil.jsonFromType(0, elementType); // put to first element in array @@ -163,7 +171,7 @@ private static ResponseInfo createProxyMethodExampleResponse(ClientMethod client } } else { // simple or LRO - jsonObject = ModelTestCaseUtil.jsonFromType(0, clientMethod.getReturnValue().getType()); + jsonObject = ModelTestCaseUtil.jsonFromType(0, clientReturnType); if (jsonObject == null) { jsonObject = new Object(); @@ -174,7 +182,7 @@ private static ResponseInfo createProxyMethodExampleResponse(ClientMethod client } verificationObjectName = "response"; - verificationNode = ModelExampleUtil.parseNode(clientMethod.getReturnValue().getType(), jsonObject); + verificationNode = ModelExampleUtil.parseNode(clientReturnType, jsonObject); } Map responseObject = new HashMap<>(); responseObject.put("body", jsonObject); @@ -183,6 +191,7 @@ private static ResponseInfo createProxyMethodExampleResponse(ClientMethod client private static boolean requiresExample(ClientMethod clientMethod) { if (clientMethod.getType() == ClientMethodType.SimpleSync + || clientMethod.getType() == ClientMethodType.SimpleSyncRestResponse || clientMethod.getType() == ClientMethodType.PagingSync // limit the scope of LRO to status code of 200 || (clientMethod.getType() == ClientMethodType.LongRunningSync diff --git a/fluentgen/src/main/java/com/azure/autorest/fluent/model/clientmodel/examplemodel/FluentMethodMockUnitTest.java b/fluentgen/src/main/java/com/azure/autorest/fluent/model/clientmodel/examplemodel/FluentMethodMockUnitTest.java index 0170f2e7de..a6a8f21d6c 100644 --- a/fluentgen/src/main/java/com/azure/autorest/fluent/model/clientmodel/examplemodel/FluentMethodMockUnitTest.java +++ b/fluentgen/src/main/java/com/azure/autorest/fluent/model/clientmodel/examplemodel/FluentMethodMockUnitTest.java @@ -5,6 +5,7 @@ import com.azure.autorest.fluent.model.clientmodel.FluentCollectionMethod; import com.azure.autorest.fluent.model.clientmodel.FluentResourceCollection; +import com.azure.autorest.model.clientmodel.IType; import com.azure.autorest.model.clientmodel.ProxyMethodExample; import com.azure.autorest.model.clientmodel.examplemodel.ExampleNode; @@ -12,6 +13,7 @@ public class FluentMethodMockUnitTest { // method with mock data private final FluentMethodExample fluentMethodExample; + private final IType fluentReturnType; private final FluentResourceCreateExample fluentResourceCreateExample; private final FluentResourceCollection resourceCollection; @@ -26,13 +28,14 @@ public class FluentMethodMockUnitTest { public FluentMethodMockUnitTest( FluentMethodExample fluentMethodExample, FluentResourceCollection resourceCollection, FluentCollectionMethod fluentCollectionMethod, - ProxyMethodExample.Response response, + IType fluentReturnType, ProxyMethodExample.Response response, String responseVerificationVariableName, ExampleNode responseVerificationNode) { this.fluentMethodExample = fluentMethodExample; this.fluentResourceCreateExample = null; this.resourceCollection = resourceCollection; this.collectionMethod = fluentCollectionMethod; + this.fluentReturnType = fluentReturnType; this.response = response; this.responseVerificationVariableName = responseVerificationVariableName; this.responseVerificationNode = responseVerificationNode; @@ -41,13 +44,14 @@ public FluentMethodMockUnitTest( public FluentMethodMockUnitTest( FluentResourceCreateExample fluentResourceCreateExample, FluentResourceCollection resourceCollection, FluentCollectionMethod collectionMethod, - ProxyMethodExample.Response response, + IType fluentReturnType, ProxyMethodExample.Response response, String responseVerificationVariableName, ExampleNode responseVerificationNode) { this.fluentMethodExample = null; this.fluentResourceCreateExample = fluentResourceCreateExample; this.resourceCollection = resourceCollection; this.collectionMethod = collectionMethod; + this.fluentReturnType = fluentReturnType; this.response = response; this.responseVerificationVariableName = responseVerificationVariableName; this.responseVerificationNode = responseVerificationNode; @@ -60,6 +64,13 @@ public FluentMethodExample getFluentMethodExample() { return fluentMethodExample; } + /** + * @return return type. It could be the inner client model type of Fluent resource create/update/get method. + */ + public IType getFluentReturnType() { + return fluentReturnType; + } + /** * @return example of resource creation, mutually exclusive with {@link #getFluentMethodExample()}. */ diff --git a/fluentgen/src/main/java/com/azure/autorest/fluent/model/javamodel/FluentJavaPackage.java b/fluentgen/src/main/java/com/azure/autorest/fluent/model/javamodel/FluentJavaPackage.java index 88db5f6c00..202e38fae9 100644 --- a/fluentgen/src/main/java/com/azure/autorest/fluent/model/javamodel/FluentJavaPackage.java +++ b/fluentgen/src/main/java/com/azure/autorest/fluent/model/javamodel/FluentJavaPackage.java @@ -14,7 +14,7 @@ import com.azure.autorest.fluent.model.clientmodel.examplemodel.FluentMethodMockUnitTest; import com.azure.autorest.fluent.model.projectmodel.Changelog; import com.azure.autorest.fluent.model.projectmodel.FluentProject; -import com.azure.autorest.fluent.template.FluentMethodTestTemplate; +import com.azure.autorest.fluent.template.FluentMethodMockTestTemplate; import com.azure.autorest.fluent.template.FluentLiveTestsTemplate; import com.azure.autorest.model.projectmodel.TextFile; import com.azure.autorest.fluent.template.ChangelogTemplate; @@ -116,9 +116,9 @@ public void addOperationUnitTest(FluentMethodMockUnitTest unitTest) { + CodeNamer.toPascalCase(unitTest.getCollectionMethod().getMethodName()) + "MockTests"; JavaFile javaFile = getJavaFileFactory().createTestFile(JavaSettings.getInstance().getPackage("generated"), className); - FluentMethodTestTemplate.ClientMethodInfo info = new FluentMethodTestTemplate.ClientMethodInfo( + FluentMethodMockTestTemplate.ClientMethodInfo info = new FluentMethodMockTestTemplate.ClientMethodInfo( className, unitTest); - FluentMethodTestTemplate.getInstance().write(info, javaFile); + FluentMethodMockTestTemplate.getInstance().write(info, javaFile); addJavaFile(javaFile); } diff --git a/fluentgen/src/main/java/com/azure/autorest/fluent/template/FluentMethodTestTemplate.java b/fluentgen/src/main/java/com/azure/autorest/fluent/template/FluentMethodMockTestTemplate.java similarity index 83% rename from fluentgen/src/main/java/com/azure/autorest/fluent/template/FluentMethodTestTemplate.java rename to fluentgen/src/main/java/com/azure/autorest/fluent/template/FluentMethodMockTestTemplate.java index ca5897e68c..6694bcc05a 100644 --- a/fluentgen/src/main/java/com/azure/autorest/fluent/template/FluentMethodTestTemplate.java +++ b/fluentgen/src/main/java/com/azure/autorest/fluent/template/FluentMethodMockTestTemplate.java @@ -4,10 +4,11 @@ package com.azure.autorest.fluent.template; import com.azure.autorest.fluent.model.clientmodel.examplemodel.FluentMethodMockUnitTest; +import com.azure.autorest.fluent.util.FluentUtils; import com.azure.autorest.model.clientmodel.ClassType; import com.azure.autorest.model.clientmodel.ClientMethod; import com.azure.autorest.model.clientmodel.IType; -import com.azure.autorest.model.clientmodel.PrimitiveType; +import com.azure.autorest.model.clientmodel.examplemodel.ExampleHelperFeature; import com.azure.autorest.model.clientmodel.examplemodel.ExampleNode; import com.azure.autorest.model.javamodel.JavaFile; import com.azure.autorest.template.IJavaTemplate; @@ -30,7 +31,7 @@ import java.util.HashSet; import java.util.Set; -public class FluentMethodTestTemplate implements IJavaTemplate { +public class FluentMethodMockTestTemplate implements IJavaTemplate { public static class ClientMethodInfo { private final String className; @@ -43,14 +44,14 @@ public ClientMethodInfo(String className, FluentMethodMockUnitTest fluentMethodM } } - private static final FluentMethodTestTemplate INSTANCE = new FluentMethodTestTemplate(); + private static final FluentMethodMockTestTemplate INSTANCE = new FluentMethodMockTestTemplate(); private static final SerializerAdapter SERIALIZER = SerializerFactory.createDefaultManagementSerializerAdapter(); - private FluentMethodTestTemplate() { + private FluentMethodMockTestTemplate() { } - public static FluentMethodTestTemplate getInstance() { + public static FluentMethodMockTestTemplate getInstance() { return INSTANCE; } @@ -77,8 +78,12 @@ public void write(ClientMethodInfo info, JavaFile javaFile) { String className = info.className; FluentMethodMockUnitTest fluentMethodMockUnitTest = info.fluentMethodMockUnitTest; ClientMethod clientMethod = fluentMethodMockUnitTest.getCollectionMethod().getInnerClientMethod(); - final boolean hasReturnValue = clientMethod.getReturnValue().getType() != PrimitiveType.Void; - IType fluentReturnType = fluentMethodMockUnitTest.getCollectionMethod().getFluentReturnType(); + IType fluentReturnType = fluentMethodMockUnitTest.getFluentReturnType(); + final boolean isResponseType = FluentUtils.isResponseType(fluentReturnType); + if (isResponseType) { + fluentReturnType = FluentUtils.getValueTypeFromResponseType(fluentReturnType); + } + final boolean hasReturnValue = fluentReturnType.asNullable() != ClassType.Void; // method invocation String clientMethodInvocationWithResponse; @@ -92,7 +97,8 @@ public void write(ClientMethodInfo info, JavaFile javaFile) { } String clientMethodInvocation = exampleMethod.getMethodContent(); if (hasReturnValue) { - clientMethodInvocationWithResponse = fluentReturnType.toString() + " response = " + clientMethodInvocation; + // hack on replaceResponseForValue, as in "update" case, "exampleMethod.getMethodContent()" would be a code block, not a single line of code invocation. + clientMethodInvocationWithResponse = fluentReturnType + " response = " + (isResponseType ? replaceResponseForValue(clientMethodInvocation) : clientMethodInvocation); } else { clientMethodInvocationWithResponse = clientMethodInvocation; } @@ -157,9 +163,17 @@ public void write(ClientMethodInfo info, JavaFile javaFile) { }); // helper method - if (!exampleMethod.getHelperFeatures().isEmpty()) { + if (exampleMethod.getHelperFeatures().contains(ExampleHelperFeature.MapOfMethod)) { ModelExampleWriter.writeMapOfMethod(classBlock); } }); } + + private static String replaceResponseForValue(String clientMethodInvocation) { + if (clientMethodInvocation.endsWith(";")) { + clientMethodInvocation = clientMethodInvocation.substring(0, clientMethodInvocation.length() - 1); + clientMethodInvocation += ".getValue();"; + } + return clientMethodInvocation; + } } diff --git a/fluentgen/src/main/java/com/azure/autorest/fluent/util/FluentUtils.java b/fluentgen/src/main/java/com/azure/autorest/fluent/util/FluentUtils.java index cf11940f88..6e96cf8aee 100644 --- a/fluentgen/src/main/java/com/azure/autorest/fluent/util/FluentUtils.java +++ b/fluentgen/src/main/java/com/azure/autorest/fluent/util/FluentUtils.java @@ -354,7 +354,9 @@ public static boolean exampleIsUpdate(String name) { return name.contains("update") && !name.contains("create"); } - public static boolean validToGenerateExample(ClientMethod clientMethod) { + public static boolean validRequestContentTypeToGenerateExample(ClientMethod clientMethod) { + // for now, only accept JSON as request body + String requestContentType = clientMethod.getProxyMethod().getRequestContentType(); return clientMethod.getProxyMethod().getExamples() != null && requiresExample(clientMethod) @@ -362,6 +364,13 @@ && requiresExample(clientMethod) && requestContentType != null && requestContentType.contains("json"); } + public static boolean validResponseContentTypeToGenerateExample(ClientMethod clientMethod) { + // for now, avoid binary as response body + + IType responseBodyType = clientMethod.getProxyMethod().getResponseBodyType(); + return !(responseBodyType == ClassType.BinaryData || responseBodyType == GenericType.FluxByteBuffer); + } + public static boolean requiresExample(ClientMethod clientMethod) { if (clientMethod.getType() == ClientMethodType.SimpleSync || clientMethod.getType() == ClientMethodType.SimpleSyncRestResponse diff --git a/javagen/src/main/java/com/azure/autorest/model/clientmodel/ProxyMethod.java b/javagen/src/main/java/com/azure/autorest/model/clientmodel/ProxyMethod.java index c24e933a03..6d82cf2b42 100644 --- a/javagen/src/main/java/com/azure/autorest/model/clientmodel/ProxyMethod.java +++ b/javagen/src/main/java/com/azure/autorest/model/clientmodel/ProxyMethod.java @@ -603,7 +603,7 @@ public Builder isResumable(boolean isResumable) { /** * Sets the metia-types in response. * - * @param responseContentTypes the metia-types in response + * @param responseContentTypes the media-types in response * @return the Builder itself */ public Builder responseContentTypes(Set responseContentTypes) { diff --git a/javagen/src/main/java/com/azure/autorest/util/ModelTestCaseUtil.java b/javagen/src/main/java/com/azure/autorest/util/ModelTestCaseUtil.java index abfd908046..36d8a56d26 100644 --- a/javagen/src/main/java/com/azure/autorest/util/ModelTestCaseUtil.java +++ b/javagen/src/main/java/com/azure/autorest/util/ModelTestCaseUtil.java @@ -14,6 +14,9 @@ import com.azure.core.util.CoreUtils; import com.azure.core.util.DateTimeRfc1123; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.time.Duration; import java.time.OffsetDateTime; import java.util.ArrayList; @@ -24,6 +27,7 @@ import java.util.Locale; import java.util.Map; import java.util.Random; +import java.util.UUID; import java.util.stream.Collectors; public class ModelTestCaseUtil { @@ -106,6 +110,8 @@ public static Object jsonFromType(int depth, IType type) { return RANDOM.nextBoolean(); } else if (type == ClassType.String) { return randomString(); + } else if (type.asNullable() == ClassType.UnixTimeLong) { + return RANDOM.nextLong() & Long.MAX_VALUE; } else if (type == ClassType.DateTime) { return randomDateTime().toString(); } else if (type == ClassType.DateTimeRfc1123) { @@ -114,6 +120,19 @@ public static Object jsonFromType(int depth, IType type) { Duration duration = Duration.parse("PT0S"); duration = duration.plusSeconds(RANDOM.nextInt(10 * 24 * 60 * 60)); return duration.toString(); + } else if (type == ClassType.UUID) { + return UUID.randomUUID().toString(); + } else if (type == ClassType.URL) { + String url = "http://example.org/"; + try { + url += URLEncoder.encode(randomString(), StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + // NOOP + } + return url; + } else if (type == ClassType.Object) { + // unknown type, use a simple string + return "data" + randomString(); } else if (type instanceof EnumType) { IType elementType = ((EnumType) type).getElementType(); List values = ((EnumType) type).getValues().stream().map(ClientEnumValue::getValue).collect(Collectors.toList()); diff --git a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/CookiecuttersharkTests.java b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/CookiecuttersharkTests.java index 5a75096162..476b39b087 100644 --- a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/CookiecuttersharkTests.java +++ b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/CookiecuttersharkTests.java @@ -17,36 +17,32 @@ public final class CookiecuttersharkTests { public void testDeserialize() { Cookiecuttershark model = BinaryData.fromString( - "{\"fishtype\":\"cookiecuttershark\",\"age\":1999845889,\"birthday\":\"2021-11-09T22:26:22Z\",\"species\":\"tcj\",\"length\":45.168953,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"vndhkrwpdapp\",\"length\":43.59222,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"vwrwj\",\"length\":48.286907,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"hutje\",\"length\":87.67903,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"dhugjzzdatqxhocd\",\"length\":25.122803,\"siblings\":[]}]}") + "{\"fishtype\":\"cookiecuttershark\",\"age\":885062254,\"birthday\":\"2021-05-27T22:50:20Z\",\"species\":\"uticndvkaozwyif\",\"length\":25.075048,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"urokft\",\"length\":81.88607,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"iwpwcuk\",\"length\":48.25244,\"siblings\":[]}]}") .toObject(Cookiecuttershark.class); - Assertions.assertEquals("tcj", model.getSpecies()); - Assertions.assertEquals(45.168953f, model.getLength()); - Assertions.assertEquals("vndhkrwpdapp", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(43.59222f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(1999845889, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2021-11-09T22:26:22Z"), model.getBirthday()); + Assertions.assertEquals("uticndvkaozwyif", model.getSpecies()); + Assertions.assertEquals(25.075048f, model.getLength()); + Assertions.assertEquals("urokft", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(81.88607f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(885062254, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-05-27T22:50:20Z"), model.getBirthday()); } @Test public void testSerialize() { Cookiecuttershark model = - new Cookiecuttershark(45.168953f, OffsetDateTime.parse("2021-11-09T22:26:22Z")) - .setSpecies("tcj") + new Cookiecuttershark(25.075048f, OffsetDateTime.parse("2021-05-27T22:50:20Z")) + .setSpecies("uticndvkaozwyif") .setSiblings( Arrays.asList( - new Fish(43.59222f).setSpecies("vndhkrwpdapp").setSiblings(Arrays.asList()), - new Fish(48.286907f).setSpecies("vwrwj").setSiblings(Arrays.asList()), - new Fish(87.67903f).setSpecies("hutje").setSiblings(Arrays.asList()), - new Fish(25.122803f) - .setSpecies("dhugjzzdatqxhocd") - .setSiblings(Arrays.asList()))) - .setAge(1999845889); + new Fish(81.88607f).setSpecies("urokft").setSiblings(Arrays.asList()), + new Fish(48.25244f).setSpecies("iwpwcuk").setSiblings(Arrays.asList()))) + .setAge(885062254); model = BinaryData.fromObject(model).toObject(Cookiecuttershark.class); - Assertions.assertEquals("tcj", model.getSpecies()); - Assertions.assertEquals(45.168953f, model.getLength()); - Assertions.assertEquals("vndhkrwpdapp", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(43.59222f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(1999845889, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2021-11-09T22:26:22Z"), model.getBirthday()); + Assertions.assertEquals("uticndvkaozwyif", model.getSpecies()); + Assertions.assertEquals(25.075048f, model.getLength()); + Assertions.assertEquals("urokft", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(81.88607f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(885062254, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-05-27T22:50:20Z"), model.getBirthday()); } } diff --git a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/GoblinsharkTests.java b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/GoblinsharkTests.java index 7caa46d8a1..a63ad8ff9e 100644 --- a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/GoblinsharkTests.java +++ b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/GoblinsharkTests.java @@ -18,40 +18,41 @@ public final class GoblinsharkTests { public void testDeserialize() { Goblinshark model = BinaryData.fromString( - "{\"fishtype\":\"goblin\",\"jawsize\":105854038,\"color\":\"RED\",\"age\":823404328,\"birthday\":\"2021-06-16T21:35:22Z\",\"species\":\"clxxwrljdo\",\"length\":70.73601,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"vkocrcjdkwtn\",\"length\":50.567795,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"biksq\",\"length\":16.933006,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"ainqpjwnzlljfm\",\"length\":18.06193,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"vmgxsab\",\"length\":49.296616,\"siblings\":[]}]}") + "{\"fishtype\":\"goblin\",\"jawsize\":1757775346,\"color\":\"gray\",\"age\":968287955,\"birthday\":\"2021-07-01T17:17:50Z\",\"species\":\"appd\",\"length\":56.1473,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"wrwjfeu\",\"length\":93.839714,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"je\",\"length\":87.67903,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"dhugjzzdatqxhocd\",\"length\":25.122803,\"siblings\":[]}]}") .toObject(Goblinshark.class); - Assertions.assertEquals("clxxwrljdo", model.getSpecies()); - Assertions.assertEquals(70.73601f, model.getLength()); - Assertions.assertEquals("vkocrcjdkwtn", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(50.567795f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(823404328, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2021-06-16T21:35:22Z"), model.getBirthday()); - Assertions.assertEquals(105854038, model.getJawsize()); - Assertions.assertEquals(GoblinSharkColor.UPPER_RED, model.getColor()); + Assertions.assertEquals("appd", model.getSpecies()); + Assertions.assertEquals(56.1473f, model.getLength()); + Assertions.assertEquals("wrwjfeu", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(93.839714f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(968287955, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-01T17:17:50Z"), model.getBirthday()); + Assertions.assertEquals(1757775346, model.getJawsize()); + Assertions.assertEquals(GoblinSharkColor.GRAY, model.getColor()); } @Test public void testSerialize() { Goblinshark model = - new Goblinshark(70.73601f, OffsetDateTime.parse("2021-06-16T21:35:22Z")) - .setSpecies("clxxwrljdo") + new Goblinshark(56.1473f, OffsetDateTime.parse("2021-07-01T17:17:50Z")) + .setSpecies("appd") .setSiblings( Arrays.asList( - new Fish(50.567795f).setSpecies("vkocrcjdkwtn").setSiblings(Arrays.asList()), - new Fish(16.933006f).setSpecies("biksq").setSiblings(Arrays.asList()), - new Fish(18.06193f).setSpecies("ainqpjwnzlljfm").setSiblings(Arrays.asList()), - new Fish(49.296616f).setSpecies("vmgxsab").setSiblings(Arrays.asList()))) - .setAge(823404328) - .setJawsize(105854038) - .setColor(GoblinSharkColor.UPPER_RED); + new Fish(93.839714f).setSpecies("wrwjfeu").setSiblings(Arrays.asList()), + new Fish(87.67903f).setSpecies("je").setSiblings(Arrays.asList()), + new Fish(25.122803f) + .setSpecies("dhugjzzdatqxhocd") + .setSiblings(Arrays.asList()))) + .setAge(968287955) + .setJawsize(1757775346) + .setColor(GoblinSharkColor.GRAY); model = BinaryData.fromObject(model).toObject(Goblinshark.class); - Assertions.assertEquals("clxxwrljdo", model.getSpecies()); - Assertions.assertEquals(70.73601f, model.getLength()); - Assertions.assertEquals("vkocrcjdkwtn", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(50.567795f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(823404328, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2021-06-16T21:35:22Z"), model.getBirthday()); - Assertions.assertEquals(105854038, model.getJawsize()); - Assertions.assertEquals(GoblinSharkColor.UPPER_RED, model.getColor()); + Assertions.assertEquals("appd", model.getSpecies()); + Assertions.assertEquals(56.1473f, model.getLength()); + Assertions.assertEquals("wrwjfeu", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(93.839714f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(968287955, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-07-01T17:17:50Z"), model.getBirthday()); + Assertions.assertEquals(1757775346, model.getJawsize()); + Assertions.assertEquals(GoblinSharkColor.GRAY, model.getColor()); } } diff --git a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/MyDerivedTypeTests.java b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/MyDerivedTypeTests.java index cfcbdf5923..5124aa4539 100644 --- a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/MyDerivedTypeTests.java +++ b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/MyDerivedTypeTests.java @@ -14,9 +14,9 @@ public final class MyDerivedTypeTests { public void testDeserialize() { MyDerivedType model = BinaryData.fromString( - "{\"kind\":\"Kind1\",\"propD1\":\"gphuticndvka\",\"propB1\":\"wyiftyhxhur\",\"helper\":{\"propBH1\":\"ftyxolniw\"}}") + "{\"kind\":\"Kind1\",\"propD1\":\"awxklr\",\"propB1\":\"lwckbasyypnddhs\",\"helper\":{\"propBH1\":\"bacphejko\"}}") .toObject(MyDerivedType.class); - Assertions.assertEquals("wyiftyhxhur", model.getPropB1()); - Assertions.assertEquals("gphuticndvka", model.getPropD1()); + Assertions.assertEquals("lwckbasyypnddhs", model.getPropB1()); + Assertions.assertEquals("awxklr", model.getPropD1()); } } diff --git a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SawsharkTests.java b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SawsharkTests.java index 01868fab20..50326e4545 100644 --- a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SawsharkTests.java +++ b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SawsharkTests.java @@ -17,32 +17,34 @@ public final class SawsharkTests { public void testDeserialize() { Sawshark model = BinaryData.fromString( - "{\"fishtype\":\"sawshark\",\"age\":1317068560,\"birthday\":\"2021-02-25T06:04:33Z\",\"species\":\"e\",\"length\":90.10362,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"b\",\"length\":0.13743639,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"mjqulngsn\",\"length\":75.88975,\"siblings\":[]}]}") + "{\"fishtype\":\"sawshark\",\"age\":422670277,\"birthday\":\"2021-06-30T08:44:34Z\",\"species\":\"jdkwtnhxbnjb\",\"length\":57.91524,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"gls\",\"length\":81.586426,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"p\",\"length\":77.7406,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"ljfmppee\",\"length\":43.36704,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"sabkyqduujitcjcz\",\"length\":99.2908,\"siblings\":[]}]}") .toObject(Sawshark.class); - Assertions.assertEquals("e", model.getSpecies()); - Assertions.assertEquals(90.10362f, model.getLength()); - Assertions.assertEquals("b", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(0.13743639f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(1317068560, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2021-02-25T06:04:33Z"), model.getBirthday()); + Assertions.assertEquals("jdkwtnhxbnjb", model.getSpecies()); + Assertions.assertEquals(57.91524f, model.getLength()); + Assertions.assertEquals("gls", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(81.586426f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(422670277, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-06-30T08:44:34Z"), model.getBirthday()); } @Test public void testSerialize() { Sawshark model = - new Sawshark(90.10362f, OffsetDateTime.parse("2021-02-25T06:04:33Z")) - .setSpecies("e") + new Sawshark(57.91524f, OffsetDateTime.parse("2021-06-30T08:44:34Z")) + .setSpecies("jdkwtnhxbnjb") .setSiblings( Arrays.asList( - new Fish(0.13743639f).setSpecies("b").setSiblings(Arrays.asList()), - new Fish(75.88975f).setSpecies("mjqulngsn").setSiblings(Arrays.asList()))) - .setAge(1317068560); + new Fish(81.586426f).setSpecies("gls").setSiblings(Arrays.asList()), + new Fish(77.7406f).setSpecies("p").setSiblings(Arrays.asList()), + new Fish(43.36704f).setSpecies("ljfmppee").setSiblings(Arrays.asList()), + new Fish(99.2908f).setSpecies("sabkyqduujitcjcz").setSiblings(Arrays.asList()))) + .setAge(422670277); model = BinaryData.fromObject(model).toObject(Sawshark.class); - Assertions.assertEquals("e", model.getSpecies()); - Assertions.assertEquals(90.10362f, model.getLength()); - Assertions.assertEquals("b", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(0.13743639f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(1317068560, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2021-02-25T06:04:33Z"), model.getBirthday()); + Assertions.assertEquals("jdkwtnhxbnjb", model.getSpecies()); + Assertions.assertEquals(57.91524f, model.getLength()); + Assertions.assertEquals("gls", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(81.586426f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(422670277, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-06-30T08:44:34Z"), model.getBirthday()); } } diff --git a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SharkTests.java b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SharkTests.java index 96f0db077d..d95444d18b 100644 --- a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SharkTests.java +++ b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SharkTests.java @@ -17,32 +17,32 @@ public final class SharkTests { public void testDeserialize() { Shark model = BinaryData.fromString( - "{\"fishtype\":\"shark\",\"age\":1323562973,\"birthday\":\"2020-12-24T20:28:32Z\",\"species\":\"hn\",\"length\":9.845084,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"wjzrnfygxgisp\",\"length\":59.519714,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"fkufublj\",\"length\":34.64574,\"siblings\":[]}]}") + "{\"fishtype\":\"shark\",\"age\":91789189,\"birthday\":\"2021-08-17T04:19:07Z\",\"species\":\"mjqulngsn\",\"length\":75.88975,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"kzgcwrwcl\",\"length\":99.26511,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"jdous\",\"length\":84.4235,\"siblings\":[]}]}") .toObject(Shark.class); - Assertions.assertEquals("hn", model.getSpecies()); - Assertions.assertEquals(9.845084f, model.getLength()); - Assertions.assertEquals("wjzrnfygxgisp", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(59.519714f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(1323562973, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2020-12-24T20:28:32Z"), model.getBirthday()); + Assertions.assertEquals("mjqulngsn", model.getSpecies()); + Assertions.assertEquals(75.88975f, model.getLength()); + Assertions.assertEquals("kzgcwrwcl", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(99.26511f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(91789189, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-08-17T04:19:07Z"), model.getBirthday()); } @Test public void testSerialize() { Shark model = - new Shark(9.845084f, OffsetDateTime.parse("2020-12-24T20:28:32Z")) - .setSpecies("hn") + new Shark(75.88975f, OffsetDateTime.parse("2021-08-17T04:19:07Z")) + .setSpecies("mjqulngsn") .setSiblings( Arrays.asList( - new Fish(59.519714f).setSpecies("wjzrnfygxgisp").setSiblings(Arrays.asList()), - new Fish(34.64574f).setSpecies("fkufublj").setSiblings(Arrays.asList()))) - .setAge(1323562973); + new Fish(99.26511f).setSpecies("kzgcwrwcl").setSiblings(Arrays.asList()), + new Fish(84.4235f).setSpecies("jdous").setSiblings(Arrays.asList()))) + .setAge(91789189); model = BinaryData.fromObject(model).toObject(Shark.class); - Assertions.assertEquals("hn", model.getSpecies()); - Assertions.assertEquals(9.845084f, model.getLength()); - Assertions.assertEquals("wjzrnfygxgisp", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(59.519714f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals(1323562973, model.getAge()); - Assertions.assertEquals(OffsetDateTime.parse("2020-12-24T20:28:32Z"), model.getBirthday()); + Assertions.assertEquals("mjqulngsn", model.getSpecies()); + Assertions.assertEquals(75.88975f, model.getLength()); + Assertions.assertEquals("kzgcwrwcl", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(99.26511f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals(91789189, model.getAge()); + Assertions.assertEquals(OffsetDateTime.parse("2021-08-17T04:19:07Z"), model.getBirthday()); } } diff --git a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SmartSalmonTests.java b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SmartSalmonTests.java index 6e13897202..b99001eadd 100644 --- a/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SmartSalmonTests.java +++ b/vanilla-tests/src/test/java/fixtures/bodycomplex/generated/SmartSalmonTests.java @@ -18,35 +18,37 @@ public final class SmartSalmonTests { public void testDeserialize() { SmartSalmon model = BinaryData.fromString( - "{\"fishtype\":\"smart_salmon\",\"college_degree\":\"ayhuy\",\"\":{},\"location\":\"odepoogin\",\"iswild\":true,\"species\":\"iheogna\",\"length\":41.474594,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"heotusiv\",\"length\":74.332695,\"siblings\":[]}]}") + "{\"fishtype\":\"smart_salmon\",\"college_degree\":\"ayhuy\",\"\":{\"inuvamiheogn\":\"datapodepoo\",\"usivye\":\"datarxzxtheo\"},\"location\":\"ciqihnhung\",\"iswild\":false,\"species\":\"rnfygxgispem\",\"length\":55.453957,\"siblings\":[{\"fishtype\":\"Fish\",\"species\":\"ufubl\",\"length\":16.258835,\"siblings\":[]},{\"fishtype\":\"Fish\",\"species\":\"eofjaeqjh\",\"length\":91.61654,\"siblings\":[]}]}") .toObject(SmartSalmon.class); - Assertions.assertEquals("iheogna", model.getSpecies()); - Assertions.assertEquals(41.474594f, model.getLength()); - Assertions.assertEquals("heotusiv", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(74.332695f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals("odepoogin", model.getLocation()); - Assertions.assertEquals(true, model.iswild()); + Assertions.assertEquals("rnfygxgispem", model.getSpecies()); + Assertions.assertEquals(55.453957f, model.getLength()); + Assertions.assertEquals("ufubl", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(16.258835f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals("ciqihnhung", model.getLocation()); + Assertions.assertEquals(false, model.iswild()); Assertions.assertEquals("ayhuy", model.getCollegeDegree()); } @Test public void testSerialize() { SmartSalmon model = - new SmartSalmon(41.474594f) - .setSpecies("iheogna") + new SmartSalmon(55.453957f) + .setSpecies("rnfygxgispem") .setSiblings( - Arrays.asList(new Fish(74.332695f).setSpecies("heotusiv").setSiblings(Arrays.asList()))) - .setLocation("odepoogin") - .setIswild(true) + Arrays.asList( + new Fish(16.258835f).setSpecies("ufubl").setSiblings(Arrays.asList()), + new Fish(91.61654f).setSpecies("eofjaeqjh").setSiblings(Arrays.asList()))) + .setLocation("ciqihnhung") + .setIswild(false) .setCollegeDegree("ayhuy") .setAdditionalProperties(mapOf("fishtype", "smart_salmon")); model = BinaryData.fromObject(model).toObject(SmartSalmon.class); - Assertions.assertEquals("iheogna", model.getSpecies()); - Assertions.assertEquals(41.474594f, model.getLength()); - Assertions.assertEquals("heotusiv", model.getSiblings().get(0).getSpecies()); - Assertions.assertEquals(74.332695f, model.getSiblings().get(0).getLength()); - Assertions.assertEquals("odepoogin", model.getLocation()); - Assertions.assertEquals(true, model.iswild()); + Assertions.assertEquals("rnfygxgispem", model.getSpecies()); + Assertions.assertEquals(55.453957f, model.getLength()); + Assertions.assertEquals("ufubl", model.getSiblings().get(0).getSpecies()); + Assertions.assertEquals(16.258835f, model.getSiblings().get(0).getLength()); + Assertions.assertEquals("ciqihnhung", model.getLocation()); + Assertions.assertEquals(false, model.iswild()); Assertions.assertEquals("ayhuy", model.getCollegeDegree()); }