Skip to content

Commit 7cd8bf2

Browse files
authored
Merge pull request #488 from RachelTucker/5_0_x_API_add_5_1
JSDK-297: updating generation for Java SDK for BP 5.1.2 API.
2 parents b308998 + 4429340 commit 7cd8bf2

File tree

9 files changed

+18317
-21
lines changed

9 files changed

+18317
-21
lines changed

contracts/5_1_0_1664144_contract.xml

Lines changed: 18268 additions & 0 deletions
Large diffs are not rendered by default.

ds3-autogen-java/src/main/java/com/spectralogic/ds3autogen/java/generators/responsemodels/HeadObjectResponseGenerator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ public ImmutableList<Arguments> toParamList(final ImmutableList<Ds3ResponseCode>
3838
new Arguments("long", "ObjectSize"),
3939
new Arguments("Status", "Status"),
4040
new Arguments("ChecksumType.Type", "BlobChecksumType"),
41-
new Arguments("ImmutableMap<Long, String>", "BlobChecksums"));
41+
new Arguments("ImmutableMap<Long, String>", "BlobChecksums"),
42+
new Arguments("ZonedDateTime", "CreationDate"),
43+
new Arguments("UUID", "VersionId"));
4244

4345
return ImmutableList.sortedCopyOf(new CustomArgumentComparator(), params);
4446
}
@@ -52,6 +54,8 @@ public ImmutableSet<String> getAllImports(final Ds3Request ds3Request) {
5254
getParentImport(),
5355
"com.spectralogic.ds3client.networking.Metadata",
5456
"com.spectralogic.ds3client.models.ChecksumType",
55-
"com.google.common.collect.ImmutableMap");
57+
"com.google.common.collect.ImmutableMap",
58+
"java.time.ZonedDateTime",
59+
"java.util.UUID");
5660
}
5761
}

ds3-autogen-java/src/main/java/com/spectralogic/ds3autogen/java/generators/responseparser/HeadObjectParserGenerator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ public ImmutableList<ResponseCode> toResponseCodeList(
5555
protected static String toExistsReturnCode(final String responseName) {
5656
return "final ChecksumType.Type blobChecksumType = getBlobChecksumType(response.getHeaders());\n" +
5757
indent(4) + "final ImmutableMap<Long, String> blobChecksumMap = getBlobChecksumMap(response.getHeaders());\n" +
58-
indent(4) + "return new " + responseName + "(blobChecksumMap, blobChecksumType, metadata, objectSize, " + responseName + ".Status.EXISTS, this.getChecksum(), this.getChecksumType());\n";
58+
indent(4) + "final ZonedDateTime creationDate = getCreationDate(response.getHeaders());\n" +
59+
indent(4) + "final UUID versionId = getVersionId(response.getHeaders());\n" +
60+
indent(4) + "return new " + responseName + "(blobChecksumMap, blobChecksumType, creationDate, metadata, objectSize, " + responseName + ".Status.EXISTS, versionId, this.getChecksum(), this.getChecksumType());\n";
5961
}
6062

6163
/**
6264
* Gets the java code for returning the response handler for an object that does not exist
6365
*/
6466
protected static String toDoesntExistReturnCode(final String responseName) {
65-
return "return new " + responseName + "(ImmutableMap.of(), ChecksumType.Type.NONE, metadata, objectSize, " + responseName + ".Status.DOESNTEXIST, this.getChecksum(), this.getChecksumType());\n";
67+
return "return new " + responseName + "(ImmutableMap.of(), ChecksumType.Type.NONE, null, metadata, objectSize, " + responseName + ".Status.DOESNTEXIST, null, this.getChecksum(), this.getChecksumType());\n";
6668
}
6769
}

ds3-autogen-java/src/main/resources/tmpls/java/copyright.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* ******************************************************************************
3-
* Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
3+
* Copyright 2014-2019 Spectra Logic Corporation. All Rights Reserved.
44
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
55
* this file except in compliance with the License. A copy of the License is located at
66
*

ds3-autogen-java/src/main/resources/tmpls/java/responseparser/head_object_parser.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import com.spectralogic.ds3client.commands.interfaces.MetadataImpl;
66
import com.spectralogic.ds3client.networking.Metadata;
77
import com.google.common.collect.ImmutableMap;
88
import com.spectralogic.ds3client.models.ChecksumType;
9+
import java.time.ZonedDateTime;
10+
import java.util.UUID;
911
<#include "../imports.ftl"/>
1012

1113
import static com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils.*;

ds3-autogen-java/src/test/java/com/spectralogic/ds3autogen/java/JavaFunctionalTests.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
public class JavaFunctionalTests {
5858

5959
private static final Logger LOG = LoggerFactory.getLogger(JavaFunctionalTests.class);
60-
private final static GeneratedCodeLogger CODE_LOGGER = new GeneratedCodeLogger(FileTypeToLog.REQUEST, LOG);
60+
private final static GeneratedCodeLogger CODE_LOGGER = new GeneratedCodeLogger(FileTypeToLog.PARSER, LOG);
6161

6262
@Rule
6363
public TemporaryFolder tempFolder = new TemporaryFolder();
@@ -2036,12 +2036,16 @@ public void headObjectRequest() throws IOException, TemplateModelException {
20362036
assertTrue(hasImport("com.spectralogic.ds3client.commands.interfaces.AbstractResponse", responseGeneratedCode));
20372037
assertTrue(hasImport("com.spectralogic.ds3client.networking.Metadata", responseGeneratedCode));
20382038
assertTrue(hasImport("com.google.common.collect.ImmutableMap", responseGeneratedCode));
2039+
assertTrue(hasImport("java.time.ZonedDateTime", responseGeneratedCode));
2040+
assertTrue(hasImport("java.util.UUID", responseGeneratedCode));
20392041

20402042
assertTrue(isReqParamOfType("metadata", "Metadata", responseName, responseGeneratedCode, false));
20412043
assertTrue(isReqParamOfType("objectSize", "long", responseName, responseGeneratedCode, false));
20422044
assertTrue(isReqParamOfType("status", "Status", responseName, responseGeneratedCode, false));
20432045
assertTrue(isReqParamOfType("blobChecksumType", "ChecksumType.Type", responseName, responseGeneratedCode, false));
20442046
assertTrue(isReqParamOfType("blobChecksums", "ImmutableMap<Long, String>", responseName, responseGeneratedCode, false));
2047+
assertTrue(isReqParamOfType("versionId", "UUID", responseName, responseGeneratedCode, false));
2048+
assertTrue(isReqParamOfType("creationDate", "ZonedDateTime", responseName, responseGeneratedCode, false));
20452049

20462050
assertTrue(responseGeneratedCode.contains("public enum Status { EXISTS, DOESNTEXIST, UNKNOWN }"));
20472051

@@ -2069,16 +2073,20 @@ public void headObjectRequest() throws IOException, TemplateModelException {
20692073
assertTrue(hasImport("com.spectralogic.ds3client.networking.Metadata", responseParserCode));
20702074
assertTrue(hasImport("com.google.common.collect.ImmutableMap", responseParserCode));
20712075
assertTrue(hasImport("com.spectralogic.ds3client.models.ChecksumType", responseParserCode));
2076+
assertTrue(hasImport("java.time.ZonedDateTime", responseParserCode));
2077+
assertTrue(hasImport("java.util.UUID", responseParserCode));
20722078
assertTrue(responseParserCode.contains("import static com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils.*;"));
20732079
assertFalse(responseParserCode.contains("import static com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils.getSizeFromHeaders;"));
20742080

20752081
// 200 response code
20762082
assertTrue(responseParserCode.contains("final ChecksumType.Type blobChecksumType = getBlobChecksumType(response.getHeaders());"));
20772083
assertTrue(responseParserCode.contains("final ImmutableMap<Long, String> blobChecksumMap = getBlobChecksumMap(response.getHeaders());"));
2078-
assertTrue(responseParserCode.contains("return new HeadObjectResponse(blobChecksumMap, blobChecksumType, metadata, objectSize, HeadObjectResponse.Status.EXISTS, this.getChecksum(), this.getChecksumType());"));
2084+
assertTrue(responseParserCode.contains("final ZonedDateTime creationDate = getCreationDate(response.getHeaders());"));
2085+
assertTrue(responseParserCode.contains("final UUID versionId = getVersionId(response.getHeaders());"));
2086+
assertTrue(responseParserCode.contains("return new HeadObjectResponse(blobChecksumMap, blobChecksumType, creationDate, metadata, objectSize, HeadObjectResponse.Status.EXISTS, versionId, this.getChecksum(), this.getChecksumType());"));
20792087

20802088
// 404 response code
2081-
assertTrue(responseParserCode.contains("return new HeadObjectResponse(ImmutableMap.of(), ChecksumType.Type.NONE, metadata, objectSize, HeadObjectResponse.Status.DOESNTEXIST, this.getChecksum(), this.getChecksumType());"));
2089+
assertTrue(responseParserCode.contains("return new HeadObjectResponse(ImmutableMap.of(), ChecksumType.Type.NONE, null, metadata, objectSize, HeadObjectResponse.Status.DOESNTEXIST, null, this.getChecksum(), this.getChecksumType());"));
20822090

20832091
assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200, 404};"));
20842092
}

ds3-autogen-java/src/test/java/com/spectralogic/ds3autogen/java/generators/responsemodels/HeadObjectResponseGenerator_Test.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ public class HeadObjectResponseGenerator_Test {
3131
@Test
3232
public void getAllImports_Test() {
3333
final ImmutableSet<String> result = generator.getAllImports(null);
34-
assertThat(result.size(), is(4));
34+
assertThat(result.size(), is(6));
3535
assertThat(result, hasItem("com.spectralogic.ds3client.networking.Metadata"));
3636
assertThat(result, hasItem("com.spectralogic.ds3client.commands.interfaces.AbstractResponse"));
3737
assertThat(result, hasItem("com.spectralogic.ds3client.models.ChecksumType"));
3838
assertThat(result, hasItem("com.google.common.collect.ImmutableMap"));
39+
assertThat(result, hasItem("java.time.ZonedDateTime"));
40+
assertThat(result, hasItem("java.util.UUID"));
3941
}
4042

4143
@Test
4244
public void toParamList_Test() {
4345
final ImmutableList<Arguments> result = generator.toParamList(null);
44-
assertThat(result.size(), is(5));
46+
assertThat(result.size(), is(7));
4547

4648
// Verify that parameters were sorted alphabetically by name
4749
assertThat(result.get(0).getName(), is("BlobChecksums"));
@@ -50,13 +52,19 @@ public void toParamList_Test() {
5052
assertThat(result.get(1).getName(), is("BlobChecksumType"));
5153
assertThat(result.get(1).getType(), is("ChecksumType.Type"));
5254

53-
assertThat(result.get(2).getName(), is("Metadata"));
54-
assertThat(result.get(2).getType(), is("Metadata"));
55+
assertThat(result.get(2).getName(), is("CreationDate"));
56+
assertThat(result.get(2).getType(), is("ZonedDateTime"));
5557

56-
assertThat(result.get(3).getName(), is("ObjectSize"));
57-
assertThat(result.get(3).getType(), is("long"));
58+
assertThat(result.get(3).getName(), is("Metadata"));
59+
assertThat(result.get(3).getType(), is("Metadata"));
5860

59-
assertThat(result.get(4).getName(), is("Status"));
60-
assertThat(result.get(4).getType(), is("Status"));
61+
assertThat(result.get(4).getName(), is("ObjectSize"));
62+
assertThat(result.get(4).getType(), is("long"));
63+
64+
assertThat(result.get(5).getName(), is("Status"));
65+
assertThat(result.get(5).getType(), is("Status"));
66+
67+
assertThat(result.get(6).getName(), is("VersionId"));
68+
assertThat(result.get(6).getType(), is("UUID"));
6169
}
6270
}

ds3-autogen-java/src/test/java/com/spectralogic/ds3autogen/java/generators/responseparser/HeadObjectParserGenerator_Test.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ public class HeadObjectParserGenerator_Test {
3434
public void toExistsReturnCode_Test() {
3535
final String expected = "final ChecksumType.Type blobChecksumType = getBlobChecksumType(response.getHeaders());\n" +
3636
" final ImmutableMap<Long, String> blobChecksumMap = getBlobChecksumMap(response.getHeaders());\n" +
37-
" return new MyResponse(blobChecksumMap, blobChecksumType, metadata, objectSize, MyResponse.Status.EXISTS, this.getChecksum(), this.getChecksumType());\n";
37+
" final ZonedDateTime creationDate = getCreationDate(response.getHeaders());\n" +
38+
" final UUID versionId = getVersionId(response.getHeaders());\n" +
39+
" return new MyResponse(blobChecksumMap, blobChecksumType, creationDate, metadata, objectSize, MyResponse.Status.EXISTS, versionId, this.getChecksum(), this.getChecksumType());\n";
3840
assertThat(toExistsReturnCode("MyResponse"), is(expected));
3941
}
4042

4143
@Test
4244
public void toDoesntExistReturnCode_Test() {
43-
final String expected = "return new MyResponse(ImmutableMap.of(), ChecksumType.Type.NONE, metadata, objectSize, MyResponse.Status.DOESNTEXIST, this.getChecksum(), this.getChecksumType());\n";
45+
final String expected = "return new MyResponse(ImmutableMap.of(), ChecksumType.Type.NONE, null, metadata, objectSize, MyResponse.Status.DOESNTEXIST, null, this.getChecksum(), this.getChecksumType());\n";
4446
assertThat(toDoesntExistReturnCode("MyResponse"), is(expected));
4547
}
4648

@@ -62,10 +64,12 @@ public void toResponseCodeList_Test() {
6264
assertThat(result.get(0).getProcessingCode(),
6365
is("final ChecksumType.Type blobChecksumType = getBlobChecksumType(response.getHeaders());\n" +
6466
" final ImmutableMap<Long, String> blobChecksumMap = getBlobChecksumMap(response.getHeaders());\n" +
65-
" return new TestResponse(blobChecksumMap, blobChecksumType, metadata, objectSize, TestResponse.Status.EXISTS, this.getChecksum(), this.getChecksumType());\n"));
67+
" final ZonedDateTime creationDate = getCreationDate(response.getHeaders());\n" +
68+
" final UUID versionId = getVersionId(response.getHeaders());\n" +
69+
" return new TestResponse(blobChecksumMap, blobChecksumType, creationDate, metadata, objectSize, TestResponse.Status.EXISTS, versionId, this.getChecksum(), this.getChecksumType());\n"));
6670

6771
assertThat(result.get(1).getCode(), is(404));
6872
assertThat(result.get(1).getProcessingCode(),
69-
is("return new TestResponse(ImmutableMap.of(), ChecksumType.Type.NONE, metadata, objectSize, TestResponse.Status.DOESNTEXIST, this.getChecksum(), this.getChecksumType());\n"));
73+
is("return new TestResponse(ImmutableMap.of(), ChecksumType.Type.NONE, null, metadata, objectSize, TestResponse.Status.DOESNTEXIST, null, this.getChecksum(), this.getChecksumType());\n"));
7074
}
7175
}

ds3-autogen-java/src/test/java/com/spectralogic/ds3autogen/java/utils/TestHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public static boolean hasCopyright(final String code) {
207207
final String copyright =
208208
"/*\n" +
209209
" * ******************************************************************************\n" +
210-
" * Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.\n" +
210+
" * Copyright 2014-2019 Spectra Logic Corporation. All Rights Reserved.\n" +
211211
" * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use\n" +
212212
" * this file except in compliance with the License. A copy of the License is located at\n" +
213213
" *\n" +

0 commit comments

Comments
 (0)