Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18,268 changes: 18,268 additions & 0 deletions contracts/5_1_0_1664144_contract.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public ImmutableList<Arguments> toParamList(final ImmutableList<Ds3ResponseCode>
new Arguments("long", "ObjectSize"),
new Arguments("Status", "Status"),
new Arguments("ChecksumType.Type", "BlobChecksumType"),
new Arguments("ImmutableMap<Long, String>", "BlobChecksums"));
new Arguments("ImmutableMap<Long, String>", "BlobChecksums"),
new Arguments("ZonedDateTime", "CreationDate"),
new Arguments("UUID", "VersionId"));

return ImmutableList.sortedCopyOf(new CustomArgumentComparator(), params);
}
Expand All @@ -52,6 +54,8 @@ public ImmutableSet<String> getAllImports(final Ds3Request ds3Request) {
getParentImport(),
"com.spectralogic.ds3client.networking.Metadata",
"com.spectralogic.ds3client.models.ChecksumType",
"com.google.common.collect.ImmutableMap");
"com.google.common.collect.ImmutableMap",
"java.time.ZonedDateTime",
"java.util.UUID");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ public ImmutableList<ResponseCode> toResponseCodeList(
protected static String toExistsReturnCode(final String responseName) {
return "final ChecksumType.Type blobChecksumType = getBlobChecksumType(response.getHeaders());\n" +
indent(4) + "final ImmutableMap<Long, String> blobChecksumMap = getBlobChecksumMap(response.getHeaders());\n" +
indent(4) + "return new " + responseName + "(blobChecksumMap, blobChecksumType, metadata, objectSize, " + responseName + ".Status.EXISTS, this.getChecksum(), this.getChecksumType());\n";
indent(4) + "final ZonedDateTime creationDate = getCreationDate(response.getHeaders());\n" +
indent(4) + "final UUID versionId = getVersionId(response.getHeaders());\n" +
indent(4) + "return new " + responseName + "(blobChecksumMap, blobChecksumType, creationDate, metadata, objectSize, " + responseName + ".Status.EXISTS, versionId, this.getChecksum(), this.getChecksumType());\n";
}

/**
* Gets the java code for returning the response handler for an object that does not exist
*/
protected static String toDoesntExistReturnCode(final String responseName) {
return "return new " + responseName + "(ImmutableMap.of(), ChecksumType.Type.NONE, metadata, objectSize, " + responseName + ".Status.DOESNTEXIST, this.getChecksum(), this.getChecksumType());\n";
return "return new " + responseName + "(ImmutableMap.of(), ChecksumType.Type.NONE, null, metadata, objectSize, " + responseName + ".Status.DOESNTEXIST, null, this.getChecksum(), this.getChecksumType());\n";
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ******************************************************************************
* Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.
* Copyright 2014-2019 Spectra Logic Corporation. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.spectralogic.ds3client.commands.interfaces.MetadataImpl;
import com.spectralogic.ds3client.networking.Metadata;
import com.google.common.collect.ImmutableMap;
import com.spectralogic.ds3client.models.ChecksumType;
import java.time.ZonedDateTime;
import java.util.UUID;
<#include "../imports.ftl"/>

import static com.spectralogic.ds3client.commands.parsers.utils.ResponseParserUtils.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
public class JavaFunctionalTests {

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

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

assertTrue(isReqParamOfType("metadata", "Metadata", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("objectSize", "long", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("status", "Status", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("blobChecksumType", "ChecksumType.Type", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("blobChecksums", "ImmutableMap<Long, String>", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("versionId", "UUID", responseName, responseGeneratedCode, false));
assertTrue(isReqParamOfType("creationDate", "ZonedDateTime", responseName, responseGeneratedCode, false));

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

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

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

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

assertTrue(responseParserCode.contains("private final int[] expectedStatusCodes = new int[]{200, 404};"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ public class HeadObjectResponseGenerator_Test {
@Test
public void getAllImports_Test() {
final ImmutableSet<String> result = generator.getAllImports(null);
assertThat(result.size(), is(4));
assertThat(result.size(), is(6));
assertThat(result, hasItem("com.spectralogic.ds3client.networking.Metadata"));
assertThat(result, hasItem("com.spectralogic.ds3client.commands.interfaces.AbstractResponse"));
assertThat(result, hasItem("com.spectralogic.ds3client.models.ChecksumType"));
assertThat(result, hasItem("com.google.common.collect.ImmutableMap"));
assertThat(result, hasItem("java.time.ZonedDateTime"));
assertThat(result, hasItem("java.util.UUID"));
}

@Test
public void toParamList_Test() {
final ImmutableList<Arguments> result = generator.toParamList(null);
assertThat(result.size(), is(5));
assertThat(result.size(), is(7));

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

assertThat(result.get(2).getName(), is("Metadata"));
assertThat(result.get(2).getType(), is("Metadata"));
assertThat(result.get(2).getName(), is("CreationDate"));
assertThat(result.get(2).getType(), is("ZonedDateTime"));

assertThat(result.get(3).getName(), is("ObjectSize"));
assertThat(result.get(3).getType(), is("long"));
assertThat(result.get(3).getName(), is("Metadata"));
assertThat(result.get(3).getType(), is("Metadata"));

assertThat(result.get(4).getName(), is("Status"));
assertThat(result.get(4).getType(), is("Status"));
assertThat(result.get(4).getName(), is("ObjectSize"));
assertThat(result.get(4).getType(), is("long"));

assertThat(result.get(5).getName(), is("Status"));
assertThat(result.get(5).getType(), is("Status"));

assertThat(result.get(6).getName(), is("VersionId"));
assertThat(result.get(6).getType(), is("UUID"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ public class HeadObjectParserGenerator_Test {
public void toExistsReturnCode_Test() {
final String expected = "final ChecksumType.Type blobChecksumType = getBlobChecksumType(response.getHeaders());\n" +
" final ImmutableMap<Long, String> blobChecksumMap = getBlobChecksumMap(response.getHeaders());\n" +
" return new MyResponse(blobChecksumMap, blobChecksumType, metadata, objectSize, MyResponse.Status.EXISTS, this.getChecksum(), this.getChecksumType());\n";
" final ZonedDateTime creationDate = getCreationDate(response.getHeaders());\n" +
" final UUID versionId = getVersionId(response.getHeaders());\n" +
" return new MyResponse(blobChecksumMap, blobChecksumType, creationDate, metadata, objectSize, MyResponse.Status.EXISTS, versionId, this.getChecksum(), this.getChecksumType());\n";
assertThat(toExistsReturnCode("MyResponse"), is(expected));
}

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

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

assertThat(result.get(1).getCode(), is(404));
assertThat(result.get(1).getProcessingCode(),
is("return new TestResponse(ImmutableMap.of(), ChecksumType.Type.NONE, metadata, objectSize, TestResponse.Status.DOESNTEXIST, this.getChecksum(), this.getChecksumType());\n"));
is("return new TestResponse(ImmutableMap.of(), ChecksumType.Type.NONE, null, metadata, objectSize, TestResponse.Status.DOESNTEXIST, null, this.getChecksum(), this.getChecksumType());\n"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static boolean hasCopyright(final String code) {
final String copyright =
"/*\n" +
" * ******************************************************************************\n" +
" * Copyright 2014-2017 Spectra Logic Corporation. All Rights Reserved.\n" +
" * Copyright 2014-2019 Spectra Logic Corporation. All Rights Reserved.\n" +
" * Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use\n" +
" * this file except in compliance with the License. A copy of the License is located at\n" +
" *\n" +
Expand Down