1+ /*
2+ * Licensed to the Apache Software Foundation (ASF) under one or more
3+ * contributor license agreements. See the NOTICE file distributed with
4+ * this work for additional information regarding copyright ownership.
5+ * The ASF licenses this file to you under the Apache License, Version 2.0
6+ * (the "License"); you may not use this file except in compliance with
7+ * the License. You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ */
117package org .apache .logging .log4j .mongodb ;
218
3- import org .junit .jupiter .api .Test ;
4-
519import static org .junit .jupiter .api .Assertions .assertEquals ;
620import static org .junit .jupiter .api .Assertions .assertNotNull ;
721import static org .junit .jupiter .api .Assertions .assertNull ;
822
23+ import org .junit .jupiter .api .Test ;
924
1025class MongoDbProviderTest {
1126
@@ -16,9 +31,6 @@ class MongoDbProviderTest {
1631 private String collectionName = "logsTest" ;
1732 private String databaseName = "loggingTest" ;
1833
19-
20-
21-
2234 @ Test
2335 void createProviderWithDatabaseAndCollectionProvidedViaConfig () {
2436
@@ -29,9 +41,14 @@ void createProviderWithDatabaseAndCollectionProvidedViaConfig() {
2941 .build ();
3042
3143 assertNotNull (provider , "Returned provider is null" );
32- assertEquals (this .collectionName , provider .getConnection ().getCollection ().getNamespace ().getCollectionName (), "Collection names do not match" );
33- assertEquals ( this .databaseName , provider .getConnection ().getCollection ().getNamespace ().getDatabaseName (), "Database names do not match" );
34-
44+ assertEquals (
45+ this .collectionName ,
46+ provider .getConnection ().getCollection ().getNamespace ().getCollectionName (),
47+ "Collection names do not match" );
48+ assertEquals (
49+ this .databaseName ,
50+ provider .getConnection ().getCollection ().getNamespace ().getDatabaseName (),
51+ "Database names do not match" );
3552 }
3653
3754 @ Test
@@ -41,49 +58,47 @@ void createProviderWithoutDatabaseName() {
4158 .setConnectionStringSource (this .validConnectionStringWithoutDatabase )
4259 .build ();
4360
44- assertNull ( provider , "Provider should be null but was not" );
45-
46-
61+ assertNull (provider , "Provider should be null but was not" );
4762 }
4863
4964 @ Test
50- void createProviderWithoutDatabaseNameWithCollectionName (){
65+ void createProviderWithoutDatabaseNameWithCollectionName () {
5166
5267 MongoDbProvider provider = MongoDbProvider .newBuilder ()
5368 .setConnectionStringSource (this .validConnectionStringWithoutDatabase )
5469 .setCollectionName (this .collectionName )
5570 .build ();
5671
57- assertNull (provider ,"Provider should be null but was not" );
58-
59-
60-
72+ assertNull (provider , "Provider should be null but was not" );
6173 }
6274
6375 @ Test
64- void createProviderWithoutCollectionName (){
76+ void createProviderWithoutCollectionName () {
6577
6678 MongoDbProvider provider = MongoDbProvider .newBuilder ()
6779 .setConnectionStringSource (this .validConnectionStringWithoutDatabase )
6880 .setDatabaseName (this .databaseName )
6981 .build ();
7082
71- assertNull (provider ,"Provider should be null but was not" );
72-
73-
83+ assertNull (provider , "Provider should be null but was not" );
7484 }
7585
7686 @ Test
77- void createProviderWithDatabaseOnConnectionString (){
87+ void createProviderWithDatabaseOnConnectionString () {
7888 MongoDbProvider provider = MongoDbProvider .newBuilder ()
7989 .setConnectionStringSource (this .validConnectionStringWithDatabase )
8090 .setCollectionName (this .collectionName )
8191 .build ();
8292
83- assertNotNull (provider ,"Provider should not be null" );
84- assertEquals (this .collectionName , provider .getConnection ().getCollection ().getNamespace ().getCollectionName (), "Provider should be null but was not" );
85- assertEquals ( "logging" , provider .getConnection ().getCollection ().getNamespace ().getDatabaseName (),"Database names do not match" );
86-
93+ assertNotNull (provider , "Provider should not be null" );
94+ assertEquals (
95+ this .collectionName ,
96+ provider .getConnection ().getCollection ().getNamespace ().getCollectionName (),
97+ "Provider should be null but was not" );
98+ assertEquals (
99+ "logging" ,
100+ provider .getConnection ().getCollection ().getNamespace ().getDatabaseName (),
101+ "Database names do not match" );
87102 }
88103
89104 @ Test
@@ -95,13 +110,14 @@ void createProviderConfigOverridesConnectionString() {
95110 .setDatabaseName (this .databaseName )
96111 .build ();
97112
98- assertNotNull (provider ,"Provider should not be null" );
99- assertEquals (this .collectionName , provider .getConnection ().getCollection ().getNamespace ().getCollectionName (), "Collection name does not match provided configuration" );
100- assertEquals (this .databaseName , provider .getConnection ().getCollection ().getNamespace ().getDatabaseName (), "Database name does not match provided configuration" );
101-
113+ assertNotNull (provider , "Provider should not be null" );
114+ assertEquals (
115+ this .collectionName ,
116+ provider .getConnection ().getCollection ().getNamespace ().getCollectionName (),
117+ "Collection name does not match provided configuration" );
118+ assertEquals (
119+ this .databaseName ,
120+ provider .getConnection ().getCollection ().getNamespace ().getDatabaseName (),
121+ "Database name does not match provided configuration" );
102122 }
103-
104-
105-
106-
107- }
123+ }
0 commit comments