Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee22d31
commit 383a09c
Showing
4 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
15 changes: 14 additions & 1 deletion
15
...java/org/eclipse/jnosql/artemis/configuration/keyvalue/BucketManagerFactoryConverter.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
3 changes: 2 additions & 1 deletion
3
...ration/src/main/resources/META-INF/services/org.eclipse.microprofile.config.spi.Converter
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
org.eclipse.jnosql.artemis.configuration.SettingsConverter | ||
org.eclipse.jnosql.artemis.configuration.keyvalue.BucketManagerConverter | ||
org.eclipse.jnosql.artemis.configuration.keyvalue.BucketManagerConverter | ||
org.eclipse.jnosql.artemis.configuration.keyvalue.BucketManagerFactoryConverter |
80 changes: 80 additions & 0 deletions
80
.../org/eclipse/jnosql/artemis/configuration/keyvalue/BucketManagerFactoryConverterTest.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,80 @@ | ||
/* | ||
* Copyright (c) 2019 Otávio Santana and others | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html | ||
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php. | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
* | ||
* Contributors: | ||
* | ||
* Otavio Santana | ||
*/ | ||
package org.eclipse.jnosql.artemis.configuration.keyvalue; | ||
|
||
import jakarta.nosql.keyvalue.BucketManagerFactory; | ||
import org.eclipse.jnosql.artemis.configuration.CDIExtension; | ||
import org.eclipse.jnosql.artemis.configuration.ConfigurationException; | ||
import org.eclipse.microprofile.config.Config; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import javax.inject.Inject; | ||
import java.util.NoSuchElementException; | ||
import java.util.UUID; | ||
|
||
@ExtendWith(CDIExtension.class) | ||
class BucketManagerFactoryConverterTest { | ||
@Inject | ||
private Config config; | ||
|
||
|
||
@Test | ||
public void shouldReturnErrorWhenThereIsNoProvider() { | ||
final String prefix = UUID.randomUUID().toString(); | ||
System.setProperty(prefix, prefix); | ||
System.setProperty(prefix + ".settings.key", "value"); | ||
System.setProperty(prefix + ".settings.key2", "value2"); | ||
Assertions.assertThrows(NoSuchElementException.class, () -> config.getValue(prefix, BucketManagerFactory.class) ); | ||
|
||
System.clearProperty(prefix); | ||
System.clearProperty(prefix + ".settings.key"); | ||
System.clearProperty(prefix + ".settings.key2"); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldReturnErrorWhenThereIsInvalidProvider() { | ||
final String prefix = UUID.randomUUID().toString(); | ||
System.setProperty(prefix, prefix); | ||
System.setProperty(prefix + ".settings.key", "value"); | ||
System.setProperty(prefix + ".settings.key2", "value2"); | ||
System.setProperty(prefix + ".provider", "java.lang.String"); | ||
Assertions.assertThrows(ConfigurationException.class, () -> config.getValue(prefix, BucketManagerFactory.class) ); | ||
|
||
System.clearProperty(prefix); | ||
System.clearProperty(prefix + ".settings.key"); | ||
System.clearProperty(prefix + ".settings.key2"); | ||
System.clearProperty(prefix + ".provider"); | ||
} | ||
|
||
|
||
@Test | ||
public void shouldReturnBucketManagerFactory() { | ||
final String prefix = UUID.randomUUID().toString(); | ||
System.setProperty(prefix, prefix); | ||
System.setProperty(prefix + ".settings.key", "value"); | ||
System.setProperty(prefix + ".settings.key2", "value2"); | ||
System.setProperty(prefix + ".provider", KeyValueConfigurationMock.class.getName()); | ||
final BucketManagerFactory managerFactory = config.getValue(prefix, BucketManagerFactory.class); | ||
|
||
Assertions.assertNotNull(managerFactory); | ||
System.clearProperty(prefix); | ||
System.clearProperty(prefix + ".settings.key"); | ||
System.clearProperty(prefix + ".settings.key2"); | ||
System.clearProperty(prefix + ".provider"); | ||
} | ||
} |
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