forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#58 from Azure/moderakh/2.0.x
added support for Conflict.getResource(.) and synced code
- Loading branch information
Showing
8 changed files
with
146 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,3 +193,4 @@ private void cleanUpGeneratedDatabases() { | |
} | ||
} | ||
} | ||
|
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
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
70 changes: 70 additions & 0 deletions
70
sdk/src/test/java/com/microsoft/azure/cosmosdb/ConflictTests.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,70 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* Copyright (c) 2018 Microsoft Corporation | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package com.microsoft.azure.cosmosdb; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ConflictTests { | ||
private String conflictAsString; | ||
|
||
@BeforeClass(groups = { "unit" }) | ||
public void setup() throws Exception { | ||
conflictAsString = IOUtils.toString( | ||
getClass().getClassLoader().getResourceAsStream("sampleConflict.json"), "UTF-8"); | ||
} | ||
|
||
@Test(groups = { "unit" }) | ||
public void getSourceResourceId() { | ||
Conflict conf = new Conflict(conflictAsString); | ||
assertThat(conf.getSourceResourceId()).isEqualTo("k6d9ALgBmD+ChB4AAAAAAA=="); | ||
} | ||
|
||
@Test(groups = { "unit" }) | ||
public void getOperationKind() { | ||
Conflict conf = new Conflict(conflictAsString); | ||
assertThat(conf.getOperationKind()).isEqualTo("create"); | ||
conf.getSourceResourceId(); | ||
} | ||
|
||
@Test(groups = { "unit" }) | ||
public void getResourceType() { | ||
Conflict conf = new Conflict(conflictAsString); | ||
assertThat(conf.getResouceType()).isEqualTo("document"); | ||
conf.getSourceResourceId(); | ||
} | ||
|
||
@Test(groups = { "unit" }) | ||
public void getResource() { | ||
Conflict conf = new Conflict(conflictAsString); | ||
Document doc = conf.getResource(Document.class); | ||
assertThat(doc.getId()).isEqualTo("0007312a-a1c5-4b54-9e39-35de2367fa33"); | ||
assertThat(doc.getInt("regionId")).isEqualTo(2); | ||
assertThat(doc.getResourceId()).isEqualTo("k6d9ALgBmD+ChB4AAAAAAA=="); | ||
assertThat(doc.getETag()).isEqualTo("\"00000200-0000-0000-0000-5b6e214b0000\""); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"id": "k6d9ALgBmD8BAAAAAAAAQA==", | ||
"_rid": "k6d9ALgBmD8BAAAAAAAAQA==", | ||
"_self": "dbs/k6d9AA==/colls/k6d9ALgBmD8=/conflicts/k6d9ALgBmD8BAAAAAAAAQA==/", | ||
"_etag": "\"00004a0f-0000-0000-0000-5b6e214b0000\"", | ||
"resourceType": "document", | ||
"operationType": "create", | ||
"resourceId": "k6d9ALgBmD+ChB4AAAAAAA==", | ||
"content": "{\"id\":\"0007312a-a1c5-4b54-9e39-35de2367fa33\",\"regionId\":2,\"regionEndpoint\":\"https://test-southeastasia.documents.azure.com:443/\",\"_rid\":\"k6d9ALgBmD+ChB4AAAAAAA==\",\"_self\":\"dbs\\/k6d9AA==\\/colls\\/k6d9ALgBmD8=\\/docs\\/k6d9ALgBmD+ChB4AAAAAAA==\\/\",\"_etag\":\"\\\"00000200-0000-0000-0000-5b6e214b0000\\\"\",\"_attachments\":\"attachments\\/\",\"_ts\":1533944139}", | ||
"_ts": 1533944139 | ||
} |