/*
 *  Copyright (c) 2017 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.jnosql.diana.redis.key;

import org.jnosql.diana.api.key.BucketManagerFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.*;

public class RedisMapStringTest {

    private BucketManagerFactory entityManagerFactory;

    @BeforeEach
    public void init() {
        entityManagerFactory = RedisTestUtils.get();
    }

    @Test
    public void shouldPutAndGetMap() {
        Map<String, String> vertebrates = entityManagerFactory.getMap("vertebrates_string", String.class, String.class);
        assertTrue(vertebrates.isEmpty());

        assertNotNull(vertebrates.put("mammals", "mammals"));
        String species = vertebrates.get("mammals");
        assertNotNull(species);
        assertEquals("mammals", vertebrates.get("mammals"));
        assertTrue(vertebrates.size() == 1);
    }

    @Test
    public void shouldVerifyExist() {
        Map<String, String> vertebrates = entityManagerFactory.getMap("vertebrates_string", String.class, String.class);
        vertebrates.put("mammals", "mammals");
        assertTrue(vertebrates.containsKey("mammals"));
        assertFalse(vertebrates.containsKey("redfish"));

        assertTrue(vertebrates.containsValue("mammals"));
        assertFalse(vertebrates.containsValue("fishes"));
    }

    @Test
    public void shouldShowKeyAndValues() {
        Map<String, String> vertebratesMap = new HashMap<>();
        vertebratesMap.put("mammals", "mammals");
        vertebratesMap.put("fishes", "fishes");
        vertebratesMap.put("amphibians", "amphibians");
        Map<String, String> vertebrates = entityManagerFactory.getMap("vertebrates_string", String.class, String.class);
        vertebrates.putAll(vertebratesMap);

        Set<String> keys = vertebrates.keySet();
        Collection<String> collectionSpecies = vertebrates.values();

        assertTrue(keys.size() == 3);
        assertTrue(collectionSpecies.size() == 3);
        assertNotNull(vertebrates.remove("mammals"));
        assertNull(vertebrates.remove("mammals"));
        assertNull(vertebrates.get("mammals"));
        assertTrue(vertebrates.size() == 2);
    }

    @AfterEach
    public void dispose() {
        Map<String, String> vertebrates = entityManagerFactory.getMap("vertebrates_string", String.class, String.class);
        vertebrates.clear();
    }

}

@@ -1025,16 +1025,248 @@
 ctory;%0A%0A
+    private static final String MAMMALS = %22mammals%22;%0A    private static final String FISHES = %22fishes%22;%0A    private static final String AMPHIBIANS = %22amphibians%22;%0A    private static final String BUCKET_NAME = %22vertebrates_string%22;%0A%0A
     @Bef
@@ -1477,36 +1477,27 @@
 .getMap(
-%22vertebrates_string%22
+BUCKET_NAME
 , String
@@ -1601,36 +1601,32 @@
 tes.put(
-%22mammals%22, %22mammals%22
+MAMMALS, MAMMALS
 ));%0A    
@@ -1662,25 +1662,23 @@
 tes.get(
-%22mammals%22
+MAMMALS
 );%0A     
@@ -1725,25 +1725,23 @@
 tEquals(
-%22mammals%22
+MAMMALS
 , verteb
@@ -1746,33 +1746,31 @@
 ebrates.get(
-%22mammals%22
+MAMMALS
 ));%0A        
@@ -1931,36 +1931,27 @@
 .getMap(
-%22vertebrates_string%22
+BUCKET_NAME
 , String
@@ -1997,36 +1997,32 @@
 tes.put(
-%22mammals%22, %22mammals%22
+MAMMALS, MAMMALS
 );%0A     
@@ -2059,25 +2059,23 @@
 ainsKey(
-%22mammals%22
+MAMMALS
 ));%0A    
@@ -2118,17 +2118,14 @@
 Key(
-%22redfish%22
+FISHES
 ));%0A
@@ -2170,25 +2170,23 @@
 nsValue(
-%22mammals%22
+MAMMALS
 ));%0A    
@@ -2227,24 +2227,22 @@
 nsValue(
-%22fishes%22
+FISHES
 ));%0A    
@@ -2390,28 +2390,24 @@
 put(
-%22mammals%22, %22mammals%22
+MAMMALS, MAMMALS
 );%0A 
@@ -2436,26 +2436,22 @@
 put(
-%22fishes%22, %22fishes%22
+FISHES, FISHES
 );%0A 
@@ -2480,34 +2480,30 @@
 put(
-%22amphibians%22, %22amphibians%22
+AMPHIBIANS, AMPHIBIANS
 );%0A 
@@ -2571,36 +2571,27 @@
 .getMap(
-%22vertebrates_string%22
+BUCKET_NAME
 , String
@@ -2903,33 +2903,31 @@
 ates.remove(
-%22mammals%22
+MAMMALS
 ));%0A        
@@ -2956,25 +2956,23 @@
 .remove(
-%22mammals%22
+MAMMALS
 ));%0A    
@@ -3002,25 +3002,23 @@
 tes.get(
-%22mammals%22
+MAMMALS
 ));%0A    
@@ -3178,36 +3178,27 @@
 .getMap(
-%22vertebrates_string%22
+BUCKET_NAME
 , String

Change String values to const