// Path: core/src/main/java/org/n52/supervisor/id/IdentifierGenerator.java
// public interface IdentifierGenerator {
// 
//     public abstract String generate();
// 
//     public abstract Collection<String> generate(int count);
// 
// }
// 
// Path: core/src/main/java/org/n52/supervisor/id/ShortAlphanumericIdentifierGenerator.java
// public class ShortAlphanumericIdentifierGenerator implements IdentifierGenerator {
// 
//     private static Logger log = LoggerFactory.getLogger(ShortAlphanumericIdentifierGenerator.class);
// 
//     public static final int ID_LENGTH = 10;
// 
//     public ShortAlphanumericIdentifierGenerator() {
//         log.debug("NEW {}", this);
//     }
// 
//     @Override
//     public String generate() {
//         return RandomStringUtils.randomAlphanumeric(ID_LENGTH).toLowerCase();
//     }
// 
//     @Override
//     public Collection<String> generate(int count) {
//         ArrayList<String> ids = new ArrayList<>();
//         for (int i = 0; i < count; i++) {
//             ids.add(generate());
//         }
//         return ids;
//     }
// 
// }


import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.n52.supervisor.id.IdentifierGenerator;
import org.n52.supervisor.id.ShortAlphanumericIdentifierGenerator;
/**
 * ﻿Copyright (C) 2013 - 2014 52°North Initiative for Geospatial Open Source Software GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.n52.supervisor;




public class Identifiers {
    
    @Test
    public void identifiersAreGenerated() {
        IdentifierGenerator gen = new ShortAlphanumericIdentifierGenerator();
        String id0 = gen.generate();
        System.out.println("Generated id: " + id0);
        String id1 = gen.generate();
        System.out.println("Generated id: " + id1);
        String id2 = gen.generate();
        System.out.println("Generated id: " + id2);
        
        assertThat(id0, not(equalTo(id1)));
        assertThat(id0, not(equalTo(id2)));
        assertThat(id1, not(equalTo(id2)));
        
        assertTrue(StringUtils.isAlphanumeric(id0));
        assertTrue(StringUtils.isAlphanumeric(id1));
        assertTrue(StringUtils.isAlphanumeric(id2));
        
        assertTrue(StringUtils.isAllLowerCase(id0.replaceAll("[\\d.]", "")));
        assertTrue(StringUtils.isAllLowerCase(id1.replaceAll("[\\d.]", "")));
        assertTrue(StringUtils.isAllLowerCase(id2.replaceAll("[\\d.]", "")));
    }
    
    @Test
    public void listOfIdentifiersIsGenerated() {
// Path: core/src/main/java/org/n52/supervisor/id/IdentifierGenerator.java
// public interface IdentifierGenerator {
// 
//     public abstract String generate();
// 
//     public abstract Collection<String> generate(int count);
// 
// }
// 
// Path: core/src/main/java/org/n52/supervisor/id/ShortAlphanumericIdentifierGenerator.java
// public class ShortAlphanumericIdentifierGenerator implements IdentifierGenerator {
// 
//     private static Logger log = LoggerFactory.getLogger(ShortAlphanumericIdentifierGenerator.class);
// 
//     public static final int ID_LENGTH = 10;
// 
//     public ShortAlphanumericIdentifierGenerator() {
//         log.debug("NEW {}", this);
//     }
// 
//     @Override
//     public String generate() {
//         return RandomStringUtils.randomAlphanumeric(ID_LENGTH).toLowerCase();
//     }
// 
//     @Override
//     public Collection<String> generate(int count) {
//         ArrayList<String> ids = new ArrayList<>();
//         for (int i = 0; i < count; i++) {
//             ids.add(generate());
//         }
//         return ids;
//     }
// 
// }


// Path: core/src/test/java/org/n52/supervisor/Identifiers.java
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.n52.supervisor.id.IdentifierGenerator;
import org.n52.supervisor.id.ShortAlphanumericIdentifierGenerator;

/**
 * ﻿Copyright (C) 2013 - 2014 52°North Initiative for Geospatial Open Source Software GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.n52.supervisor;




public class Identifiers {
    
    @Test
    public void identifiersAreGenerated() {
        IdentifierGenerator gen = new ShortAlphanumericIdentifierGenerator();
        String id0 = gen.generate();
        System.out.println("Generated id: " + id0);
        String id1 = gen.generate();
        System.out.println("Generated id: " + id1);
        String id2 = gen.generate();
        System.out.println("Generated id: " + id2);
        
        assertThat(id0, not(equalTo(id1)));
        assertThat(id0, not(equalTo(id2)));
        assertThat(id1, not(equalTo(id2)));
        
        assertTrue(StringUtils.isAlphanumeric(id0));
        assertTrue(StringUtils.isAlphanumeric(id1));
        assertTrue(StringUtils.isAlphanumeric(id2));
        
        assertTrue(StringUtils.isAllLowerCase(id0.replaceAll("[\\d.]", "")));
        assertTrue(StringUtils.isAllLowerCase(id1.replaceAll("[\\d.]", "")));
        assertTrue(StringUtils.isAllLowerCase(id2.replaceAll("[\\d.]", "")));
    }
    
    @Test
    public void listOfIdentifiersIsGenerated() {
        IdentifierGenerator gen = new ShortAlphanumericIdentifierGenerator();