Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

Commit

Permalink
OGM-1588 Checkstyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jyemin authored and DavideD committed Sep 3, 2024
1 parent 4f8c32c commit 5ac9e00
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1243,15 +1243,16 @@ private ClosableIterator<Tuple> doFind(MongoDBQueryDescriptor query, QueryParame
orderby = (Document) criteria.get( "$orderby" );
}

if ( criteria.containsKey( "$maxTimeMS") ) {
prepareFind.maxTime(criteria.getInteger("$maxTimeMS"), TimeUnit.MILLISECONDS);
if ( criteria.containsKey( "$maxTimeMS" ) ) {
prepareFind.maxTime( criteria.getInteger( "$maxTimeMS" ), TimeUnit.MILLISECONDS );
}

if ( criteria.containsKey( "$hint") ) {
if ( criteria.containsKey( "$hint" ) ) {
Object hint = criteria.get( "$hint" );
if ( hint instanceof String ) {
prepareFind.hintString( (String) hint );
} else if ( hint instanceof Bson ) {
}
else if ( hint instanceof Bson ) {
prepareFind.hint( (Bson) hint );
}
}
Expand All @@ -1267,7 +1268,8 @@ private ClosableIterator<Tuple> doFind(MongoDBQueryDescriptor query, QueryParame
if ( criteria.containsKey( "$comment" ) ) {
prepareFind.comment( criteria.getString( "$comment" ) );
}
} else {
}
else {
prepareFind.filter( criteria );
}

Expand Down Expand Up @@ -1522,11 +1524,11 @@ private static WriteConcern getWriteConcern(Document obj) {
if ( w instanceof Number ) {
wc = new WriteConcern( ( (Number) w ).intValue() );
}
if (t != null) {
wc = wc.withWTimeout(t, TimeUnit.MILLISECONDS);
if ( t != null ) {
wc = wc.withWTimeout( t, TimeUnit.MILLISECONDS );
}
if (j != null) {
wc = wc.withJournal(j);
if ( j != null ) {
wc = wc.withJournal( j );
}
}
return wc;
Expand Down Expand Up @@ -1862,7 +1864,7 @@ else if ( writeConcern.getWObject() instanceof String ) {
wObject = Math.max( original.getW(), writeConcern.getW() );
}

wTimeoutMS = Math.min( original.getWTimeout(TimeUnit.MILLISECONDS), writeConcern.getWTimeout(TimeUnit.MILLISECONDS) );
wTimeoutMS = Math.min( original.getWTimeout( TimeUnit.MILLISECONDS ), writeConcern.getWTimeout( TimeUnit.MILLISECONDS ) );

if ( original.getJournal() == null ) {
journal = writeConcern.getJournal();
Expand All @@ -1875,10 +1877,10 @@ else if ( writeConcern.getJournal() == null ) {
}

if ( wObject instanceof String ) {
return new WriteConcern( (String) wObject).withWTimeout(wTimeoutMS, TimeUnit.MILLISECONDS).withJournal(journal);
return new WriteConcern( (String) wObject ).withWTimeout( wTimeoutMS, TimeUnit.MILLISECONDS ).withJournal( journal );
}
else {
return new WriteConcern( (int) wObject).withWTimeout(wTimeoutMS, TimeUnit.MILLISECONDS).withJournal(journal);
return new WriteConcern( (int) wObject ).withWTimeout( wTimeoutMS, TimeUnit.MILLISECONDS ).withJournal( journal );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public MongoCredential buildCredential() {
return authenticationMechanism.createCredential(
getUsername(),
getAuthenticationDatabaseName(),
getPassword());
getPassword() );
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void testSuccessfulIndexCreation() throws Exception {
indexMap.get( "author_idx" ).toJson( jsonWriterSettings ) );
// TODO OGM-1080: the order should be -1 but we are waiting for ORM 5.2 which exposes this value and allows us to retrieve it
assertJsonEquals( "{ 'v' : 2 , 'key' : { 'name' : 1} , 'name' : 'name_idx' , 'ns' : 'ogm_test_database.T_POEM' , 'expireAfterSeconds' : { '$numberLong' : '10' }}",
indexMap.get( "name_idx" ).toJson( jsonWriterSettings) );
indexMap.get( "name_idx" ).toJson( jsonWriterSettings ) );
assertJsonEquals( "{ 'v' : 2 , 'unique' : true , 'key' : { 'author' : 1 , 'name' : 1} , 'name' : 'author_name_idx' , 'ns' : 'ogm_test_database.T_POEM' , 'sparse' : true}",
indexMap.get( "author_name_idx" ).toJson( jsonWriterSettings ) );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void setupBuilder() {
@Test
public void testWriteConcernGivenByTypeOnGlobalLevel() throws Exception {
mongoOptions
.writeConcern( WriteConcernType.REPLICA_ACKNOWLEDGED);
.writeConcern( WriteConcernType.REPLICA_ACKNOWLEDGED );

OptionsContainer options = getSource().getGlobalOptions();
assertThat( options.getUnique( WriteConcernOption.class ) ).isEqualTo( WriteConcern.W2 );
Expand All @@ -62,7 +62,7 @@ public void testWriteConcernGivenByInstanceOnGlobalLevel() throws Exception {
@Test
public void testWriteConcernGivenByTypePriority() throws Exception {
mongoOptions
.writeConcern( WriteConcernType.REPLICA_ACKNOWLEDGED)
.writeConcern( WriteConcernType.REPLICA_ACKNOWLEDGED )
.entity( ExampleForMongoDBMapping.class )
.writeConcern( WriteConcernType.MAJORITY )
.property( "content", ElementType.FIELD )
Expand All @@ -75,7 +75,7 @@ public void testWriteConcernGivenByTypePriority() throws Exception {
assertThat( options.getUnique( WriteConcernOption.class ) ).isEqualTo( WriteConcern.MAJORITY );

options = getSource().getPropertyOptions( ExampleForMongoDBMapping.class, "content" );
assertThat( options.getUnique( WriteConcernOption.class ) ).isEqualTo( WriteConcern.ACKNOWLEDGED.withJournal(true) );
assertThat( options.getUnique( WriteConcernOption.class ) ).isEqualTo( WriteConcern.ACKNOWLEDGED.withJournal( true ) );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void shouldApplyWriteConcernConfiguredOnPropertyLevelForCreationOfAssocia

TestHelper.configureOptionsFor( settings, MongoDB.class )
.entity( GolfPlayer.class )
.writeConcern( WriteConcernType.REPLICA_ACKNOWLEDGED)
.writeConcern( WriteConcernType.REPLICA_ACKNOWLEDGED )
.property( "playedCourses", ElementType.FIELD )
.writeConcern( WriteConcernType.ACKNOWLEDGED );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MongoDBQueryParsingTest extends OgmTestCase {
private Log log = LoggerFactory.make( MethodHandles.lookup() );

@SuppressWarnings("deprecation")
private JsonWriterSettings jsonWriterSettings = JsonWriterSettings.builder().outputMode( JsonMode.STRICT ).build();
private JsonWriterSettings jsonWriterSettings = JsonWriterSettings.builder().outputMode( JsonMode.STRICT ).build();

private QueryParser queryParser;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class MongoDBTestHelper extends BaseGridDialectTestHelper implements Grid
private static final Log log = LoggerFactory.make( MethodHandles.lookup() );

@SuppressWarnings("deprecation")
private static final JsonWriterSettings jsonWriterSettings = JsonWriterSettings.builder().outputMode( JsonMode.STRICT ).build();
private static final JsonWriterSettings jsonWriterSettings = JsonWriterSettings.builder().outputMode( JsonMode.STRICT ).build();

static {
// Read host and port from environment variable
Expand Down

0 comments on commit 5ac9e00

Please sign in to comment.