Skip to content

Commit

Permalink
Merged latest changes from main after resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
inv-jishnu committed Jan 13, 2025
2 parents f6c54ec + 822db19 commit b92758c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ subprojects {
postgresqlDriverVersion = '42.7.4'
oracleDriverVersion = '21.16.0.0'
sqlserverDriverVersion = '11.2.3.jre8'
sqliteDriverVersion = '3.47.1.0'
sqliteDriverVersion = '3.47.2.0'
yugabyteDriverVersion = '42.7.3-yb-2'
mariadDbDriverVersion = '3.5.1'
picocliVersion = '4.7.6'
commonsTextVersion = '1.13.0'
junitVersion = '5.11.4'
commonsLangVersion = '3.17.0'
assertjVersion = '3.27.0'
assertjVersion = '3.27.2'
mockitoVersion = '4.11.0'
spotbugsVersion = '4.8.6'
errorproneVersion = '2.10.0'
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/com/scalar/db/api/AbacOperationAttributes.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.scalar.db.api;

import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.Optional;

Expand All @@ -16,6 +17,11 @@ public static void setReadTag(Map<String, String> attributes, String policyName,
attributes.put(READ_TAG_PREFIX + policyName, readTag);
}

public static void setReadTag(
ImmutableMap.Builder<String, String> attributesBuilder, String policyName, String readTag) {
attributesBuilder.put(READ_TAG_PREFIX + policyName, readTag);
}

public static void clearReadTag(Map<String, String> attributes, String policyName) {
attributes.remove(READ_TAG_PREFIX + policyName);
}
Expand All @@ -29,6 +35,11 @@ public static void setWriteTag(
attributes.put(WRITE_TAG_PREFIX + policyName, writeTag);
}

public static void setWriteTag(
ImmutableMap.Builder<String, String> attributesBuilder, String policyName, String writeTag) {
attributesBuilder.put(WRITE_TAG_PREFIX + policyName, writeTag);
}

public static void clearWriteTag(Map<String, String> attributes, String policyName) {
attributes.remove(WRITE_TAG_PREFIX + policyName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ public enum CoreError implements ScalarDbError {
"Something went wrong while converting the ScalarDB values to strings. The table metadata and Value datatype probably do not match.",
"",
""),

//
// Errors for the concurrency error category
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import com.google.common.collect.ImmutableMap;
import com.scalar.db.io.Key;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -11,7 +12,7 @@
public class AbacOperationAttributesTest {

@Test
public void setReadTag_ShouldSetReadTag() {
public void setReadTag_MapGiven_ShouldSetReadTag() {
// Arrange
Map<String, String> attributes = new HashMap<>();
String policyName = "policyName";
Expand All @@ -25,6 +26,21 @@ public void setReadTag_ShouldSetReadTag() {
.containsEntry(AbacOperationAttributes.READ_TAG_PREFIX + policyName, readTag);
}

@Test
public void setReadTag_ImmutableMapBuilderGiven_ShouldSetReadTag() {
// Arrange
ImmutableMap.Builder<String, String> attributesBuilder = ImmutableMap.builder();
String policyName = "policyName";
String readTag = "readTag";

// Act
AbacOperationAttributes.setReadTag(attributesBuilder, policyName, readTag);

// Assert
assertThat(attributesBuilder.build())
.containsEntry(AbacOperationAttributes.READ_TAG_PREFIX + policyName, readTag);
}

@Test
public void clearReadTag_ShouldClearReadTag() {
// Arrange
Expand Down Expand Up @@ -60,7 +76,7 @@ public void clearReadTags_ShouldClearReadTags() {
}

@Test
public void setWriteTag_ShouldSetWriteTag() {
public void setWriteTag_MapGiven_ShouldSetWriteTag() {
// Arrange
Map<String, String> attributes = new HashMap<>();
String policyName = "policyName";
Expand All @@ -74,6 +90,21 @@ public void setWriteTag_ShouldSetWriteTag() {
.containsEntry(AbacOperationAttributes.WRITE_TAG_PREFIX + policyName, writeTag);
}

@Test
public void setWriteTag_ImmutableMapBuilderGiven_ShouldSetWriteTag() {
// Arrange
ImmutableMap.Builder<String, String> attributesBuilder = ImmutableMap.builder();
String policyName = "policyName";
String writeTag = "writeTag";

// Act
AbacOperationAttributes.setWriteTag(attributesBuilder, policyName, writeTag);

// Assert
assertThat(attributesBuilder.build())
.containsEntry(AbacOperationAttributes.WRITE_TAG_PREFIX + policyName, writeTag);
}

@Test
public void clearWriteTag_ShouldClearWriteTag() {
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ void startExport_givenValidDataWithoutPartitionKey_shouldGenerateOutputFile()
storage))
.thenReturn(scanner);
Mockito.when(scanner.iterator()).thenReturn(results.iterator());
try (BufferedWriter writer = new BufferedWriter(Files.newBufferedWriter(
Paths.get(filePath),
Charset.defaultCharset(), // Explicitly use the default charset
StandardOpenOption.CREATE,
StandardOpenOption.APPEND))) {
try (BufferedWriter writer =
new BufferedWriter(
Files.newBufferedWriter(
Paths.get(filePath),
Charset.defaultCharset(), // Explicitly use the default charset
StandardOpenOption.CREATE,
StandardOpenOption.APPEND))) {
exportManager.startExport(exportOptions, mockData, writer);
}
File file = new File(filePath);
Expand Down Expand Up @@ -113,11 +115,13 @@ void startExport_givenPartitionKey_shouldGenerateOutputFile()
storage))
.thenReturn(scanner);
Mockito.when(scanner.iterator()).thenReturn(results.iterator());
try (BufferedWriter writer = new BufferedWriter(Files.newBufferedWriter(
Paths.get(filePath),
Charset.defaultCharset(), // Explicitly use the default charset
StandardOpenOption.CREATE,
StandardOpenOption.APPEND))) {
try (BufferedWriter writer =
new BufferedWriter(
Files.newBufferedWriter(
Paths.get(filePath),
Charset.defaultCharset(), // Explicitly use the default charset
StandardOpenOption.CREATE,
StandardOpenOption.APPEND))) {
exportManager.startExport(exportOptions, mockData, writer);
}
File file = new File(filePath);
Expand Down Expand Up @@ -158,11 +162,13 @@ void startExport_givenPartitionKeyAndFileFormatCsv_shouldGenerateOutputFile()
storage))
.thenReturn(scanner);
Mockito.when(scanner.iterator()).thenReturn(results.iterator());
try (BufferedWriter writer = new BufferedWriter(Files.newBufferedWriter(
Paths.get(filePath),
Charset.defaultCharset(), // Explicitly use the default charset
StandardOpenOption.CREATE,
StandardOpenOption.APPEND))) {
try (BufferedWriter writer =
new BufferedWriter(
Files.newBufferedWriter(
Paths.get(filePath),
Charset.defaultCharset(), // Explicitly use the default charset
StandardOpenOption.CREATE,
StandardOpenOption.APPEND))) {
exportManager.startExport(exportOptions, mockData, writer);
}
File file = new File(filePath);
Expand Down

0 comments on commit b92758c

Please sign in to comment.