Skip to content

Commit

Permalink
creates bucket managager detail
Browse files Browse the repository at this point in the history
  • Loading branch information
otaviojava committed Sep 28, 2019
1 parent ee22d31 commit 383a09c
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 2 deletions.
@@ -1,7 +1,20 @@
/*
* 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.Settings;
import jakarta.nosql.keyvalue.BucketManager;
import jakarta.nosql.keyvalue.BucketManagerFactory;
import jakarta.nosql.keyvalue.KeyValueConfiguration;
import jakarta.nosql.mapping.reflection.Reflections;
Expand Down
@@ -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
@@ -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");
}
}
@@ -1,3 +1,17 @@
/*
* 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.Settings;
Expand All @@ -11,6 +25,7 @@
import java.util.Set;

public class KeyValueConfigurationMock implements KeyValueConfiguration {

@Override
public BucketManagerFactory get() {
return new BucketManagerFactoryMock(Settings.builder().build());
Expand Down

0 comments on commit 383a09c

Please sign in to comment.