DATAMONGO-2545 - Polishing.

Fix warnings and typos.

Original pull request: #864.
This commit is contained in:
Mark Paluch
2020-05-26 09:51:23 +02:00
parent fde59411da
commit 68de8e57be
2 changed files with 10 additions and 8 deletions

View File

@@ -176,6 +176,7 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec<Document>
return this.decode(reader, DecoderContext.builder().build());
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Document decode(final BsonReader reader, final DecoderContext decoderContext) {
@@ -203,12 +204,13 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec<Document>
try {
Object value = readValue(reader, decoderContext);
if (value instanceof Map) {
if (value instanceof Map<?, ?>) {
if (!((Map) value).isEmpty()) {
return new Document((Map) value);
return new Document((Map<String, Object>) value);
}
}
} catch (Exception ex) {
e.addSuppressed(ex);
throw e;
}
}

View File

@@ -269,7 +269,7 @@ public class ParameterBindingJsonReaderUnitTests {
}
@Test // DATAMONGO-2545
void shouldABindArgumentsViaIndexInSpelExpressions() {
public void shouldABindArgumentsViaIndexInSpelExpressions() {
Object[] args = new Object[] { "yess", "nooo" };
StandardEvaluationContext evaluationContext = (StandardEvaluationContext) EvaluationContextProvider.DEFAULT
@@ -284,7 +284,7 @@ public class ParameterBindingJsonReaderUnitTests {
}
@Test // DATAMONGO-2545
void shouldAllowMethodArgumentPlaceholdersInSpelExpressions/*becuase this worked before*/() {
public void shouldAllowMethodArgumentPlaceholdersInSpelExpressions/*becuase this worked before*/() {
Object[] args = new Object[] { "yess", "nooo" };
StandardEvaluationContext evaluationContext = (StandardEvaluationContext) EvaluationContextProvider.DEFAULT
@@ -299,7 +299,7 @@ public class ParameterBindingJsonReaderUnitTests {
}
@Test // DATAMONGO-2545
void shouldAllowMethodArgumentPlaceholdersInQuotedSpelExpressions/*becuase this worked before*/() {
public void shouldAllowMethodArgumentPlaceholdersInQuotedSpelExpressions/*because this worked before*/() {
Object[] args = new Object[] { "yess", "nooo" };
StandardEvaluationContext evaluationContext = (StandardEvaluationContext) EvaluationContextProvider.DEFAULT
@@ -314,7 +314,7 @@ public class ParameterBindingJsonReaderUnitTests {
}
@Test // DATAMONGO-2545
void evaluatesSpelExpressionDefiningEntireQuery() {
public void evaluatesSpelExpressionDefiningEntireQuery() {
Object[] args = new Object[] {};
StandardEvaluationContext evaluationContext = (StandardEvaluationContext) EvaluationContextProvider.DEFAULT
@@ -322,7 +322,7 @@ public class ParameterBindingJsonReaderUnitTests {
evaluationContext.setRootObject(new DummySecurityObject(new DummyWithId("wonderwoman")));
String json = "?#{ T(" + this.getClass().getName()
+ ").isBatman() ? {'_class': { '$eq' : 'region' }} : { '$and' : { {'_class': { '$eq' : 'region' } }, {'user.superviser': principal.id } } } }";
+ ").isBatman() ? {'_class': { '$eq' : 'region' }} : { '$and' : { {'_class': { '$eq' : 'region' } }, {'user.supervisor': principal.id } } } }";
ParameterBindingJsonReader reader = new ParameterBindingJsonReader(json,
new ParameterBindingContext((index) -> args[index], new SpelExpressionParser(), evaluationContext));
@@ -330,7 +330,7 @@ public class ParameterBindingJsonReaderUnitTests {
assertThat(target)
.isEqualTo(new Document("$and", Arrays.asList(new Document("_class", new Document("$eq", "region")),
new Document("user.superviser", "wonderwoman"))));
new Document("user.supervisor", "wonderwoman"))));
}
private static Document parse(String json, Object... args) {