001/*
002 * Copyright 2023 the original author or authors.
003 * <p>
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * <p>
008 * https://www.apache.org/licenses/LICENSE-2.0
009 * <p>
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package de.cuioss.test.generator.domain;
017
018import static de.cuioss.test.generator.Generators.fixedValues;
019
020import java.util.ArrayList;
021import java.util.List;
022
023import de.cuioss.test.generator.TypedGenerator;
024import de.cuioss.test.generator.internal.net.java.quickcheck.generator.PrimitiveGenerators;
025import de.cuioss.tools.string.Joiner;
026
027/**
028 * Provides Subjects for messages
029 *
030 * @author Oliver Wolff
031 *
032 */
033public class MailSubjectGenerator implements TypedGenerator<String> {
034
035    private final TypedGenerator<String> prefixes = fixedValues("Re:", "Fw:", "Answ:", "Yep:");
036    private final TypedGenerator<String> contents = fixedValues("Hello", "Patient", "Document", "Record", "Yes", "No",
037            "unknown", "Disease", "Hospital", "Doctor", "Healthy", "Not seen", "Referral", "Message", "Injury",
038            "See Also", "Payment", "Registration", "Physician");
039
040    @Override
041    public String next() {
042        final List<String> elements = new ArrayList<>();
043        for (var i = 0; i < PrimitiveGenerators.integers(0, 3).next(); i++) {
044            elements.add(prefixes.next());
045        }
046        for (var i = 0; i < PrimitiveGenerators.integers(0, 7).next(); i++) {
047            elements.add(contents.next());
048        }
049        return Joiner.on(' ').join(elements);
050    }
051
052}