import "copyright.stg"
import "primitiveEquals.stg"
import "primitiveLiteral.stg"

isTest() ::= "true"

targetPath() ::= "org/eclipse/collections/impl/bag/immutable/primitive"

fileName(primitive) ::= "Immutable<primitive.name>SingletonBagTest"

class(primitive) ::= <<
<body(primitive.type, primitive.name, primitive.wrapperName)>
>>

body(type, name, wrapperName) ::= <<
<copyright()>

package org.eclipse.collections.impl.bag.immutable.primitive;

import org.eclipse.collections.api.bag.primitive.Immutable<name>Bag;
import org.eclipse.collections.impl.bag.mutable.primitive.<name>HashBag;
import org.eclipse.collections.impl.factory.primitive.<name>Bags;
import org.eclipse.collections.impl.math.Mutable<wrapperName>;
import org.junit.Assert;
import org.junit.Test;
import org.eclipse.collections.impl.factory.primitive.<name>Sets;
import org.eclipse.collections.api.set.primitive.Immutable<name>Set;

/**
 * JUnit test for {@link Immutable<name>SingletonBag}.
 * This file was automatically generated from template file immutablePrimitiveSingletonBagTest.stg.
 */
public class Immutable<name>SingletonBagTest extends AbstractImmutable<name>BagTestCase
{
    @Override
    protected final Immutable<name>Bag classUnderTest()
    {
        return <name>Bags.immutable.of(<(literal.(type))("1")>);
    }

    @Override
    @Test
    public void forEachWithOccurrences()
    {
        StringBuilder stringBuilder = new StringBuilder();
        this.classUnderTest().forEachWithOccurrences((<type> argument1, int argument2) -> stringBuilder.append(argument1).append(argument2));
        String string = stringBuilder.toString();
        Assert.assertEquals("<(toStringLiteral.(type))("1")>1", string);
    }

    @Override
    @Test
    public void selectByOccurrences()
    {
        Immutable<name>SingletonBag bag = new Immutable<name>SingletonBag(<(literal.(type))("1")>);
        Immutable<name>Bag filtered1 = bag.selectByOccurrences(i -> i > 0);
        Assert.assertEquals(<name>HashBag.newBagWith(<["1"]:(literal.(type))(); separator=", ">), filtered1);
        Immutable<name>Bag filtered2 = bag.selectByOccurrences(i -> i > 1);
        Assert.assertEquals(<name>Bags.immutable.empty(), filtered2);
    }

    @Override
    @Test
    public void selectDuplicates()
    {
        Immutable<name>SingletonBag bag = new Immutable<name>SingletonBag(<(literal.(type))("1")>);
        Assert.assertEquals(<name>HashBag.newBagWith(), bag.selectDuplicates());
    }

    @Override
    @Test
    public void selectUnique()
    {
        super.selectUnique();

        Immutable<name>Bag bag = this.classUnderTest();
        Immutable<name>Set expected = <name>Sets.immutable.with(<(literal.(type))("1")>);
        Immutable<name>Set actual = bag.selectUnique();
        Assert.assertEquals(expected, actual);
    }

    @Override
    @Test
    public void injectInto()
    {
        super.injectInto();

        Immutable<name>SingletonBag iterable = new Immutable<name>SingletonBag(<(literal.(type))("1")>);
        Mutable<wrapperName> result = iterable.injectInto(new Mutable<wrapperName>(<(literal.(type))("1")>), Mutable<wrapperName>::add);
        Assert.assertEquals(new Mutable<wrapperName>(<(literal.(type))("2")>), result);
    }
}

>>
