-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
220 additions
and
18 deletions.
There are no files selected for viewing
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
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
81 changes: 81 additions & 0 deletions
81
server/src/main/java/com/adobe/testing/s3mock/dto/VersioningConfiguration.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,81 @@ | ||
/* | ||
* Copyright 2017-2024 Adobe. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.adobe.testing.s3mock.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonRootName; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
|
||
/** | ||
* <a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_VersioningConfiguration.html">API Reference</a>. | ||
*/ | ||
@JsonRootName("VersioningConfiguration") | ||
public record VersioningConfiguration( | ||
@JsonProperty("MfaDelete") | ||
MFADelete mfaDelete, | ||
@JsonProperty("Status") | ||
Status status, | ||
//workaround for adding xmlns attribute to root element only. | ||
@JacksonXmlProperty(isAttribute = true, localName = "xmlns") | ||
String xmlns | ||
) { | ||
|
||
public VersioningConfiguration { | ||
if (xmlns == null) { | ||
xmlns = "http://s3.amazonaws.com/doc/2006-03-01/"; | ||
} | ||
} | ||
|
||
enum MFADelete { | ||
ENABLED("Enabled"), | ||
DISABLED("Disabled"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator | ||
MFADelete(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return value; | ||
} | ||
} | ||
|
||
enum Status { | ||
ENABLED("Enabled"), | ||
SUSPENDED("Suspended"); | ||
|
||
private final String value; | ||
|
||
@JsonCreator | ||
Status(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return value; | ||
} | ||
} | ||
|
||
} |
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
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
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
44 changes: 44 additions & 0 deletions
44
server/src/test/kotlin/com/adobe/testing/s3mock/dto/VersioningConfigurationTest.kt
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,44 @@ | ||
/* | ||
* Copyright 2017-2024 Adobe. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.adobe.testing.s3mock.dto | ||
|
||
import com.adobe.testing.s3mock.dto.DtoTestUtil.deserialize | ||
import com.adobe.testing.s3mock.dto.DtoTestUtil.serializeAndAssert | ||
import com.adobe.testing.s3mock.dto.VersioningConfiguration.MFADelete | ||
import com.adobe.testing.s3mock.dto.VersioningConfiguration.Status | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.TestInfo | ||
import java.io.IOException | ||
|
||
internal class VersioningConfigurationTest { | ||
|
||
@Test | ||
@Throws(IOException::class) | ||
fun testSerialization(testInfo: TestInfo) { | ||
val iut = VersioningConfiguration(null, Status.SUSPENDED, null) | ||
serializeAndAssert(iut, testInfo) | ||
} | ||
|
||
@Test | ||
@Throws(IOException::class) | ||
fun testDeserialization(testInfo: TestInfo) { | ||
val iut = deserialize(VersioningConfiguration::class.java, testInfo) | ||
assertThat(iut.status).isEqualTo(Status.ENABLED) | ||
assertThat(iut.mfaDelete).isEqualTo(MFADelete.ENABLED) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...esources/com/adobe/testing/s3mock/dto/VersioningConfigurationTest_testDeserialization.xml
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,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2017-2024 Adobe. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | ||
<Status>Enabled</Status> | ||
<MfaDelete>Enabled</MfaDelete> | ||
</VersioningConfiguration> |
21 changes: 21 additions & 0 deletions
21
.../resources/com/adobe/testing/s3mock/dto/VersioningConfigurationTest_testSerialization.xml
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,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2017-2024 Adobe. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> | ||
<Status>Suspended</Status> | ||
</VersioningConfiguration> |