-
Notifications
You must be signed in to change notification settings - Fork 586
/
abstractImmutableObjectPrimitiveMapTestCase.stg
112 lines (90 loc) · 4.07 KB
/
abstractImmutableObjectPrimitiveMapTestCase.stg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import "copyright.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"
import "primitiveEquals.stg"
skipBoolean() ::= "true"
isTest() ::= "true"
targetPath() ::= "org/eclipse/collections/impl/map/immutable/primitive"
fileName(primitive) ::= "AbstractImmutableObject<primitive.name>MapTestCase"
class(primitive) ::= <<
<body(primitive.type, primitive.name, primitive.wrapperName)>
>>
body(type, name, wrapperName) ::= <<
<copyright()>
package org.eclipse.collections.impl.map.immutable.primitive;
import org.eclipse.collections.api.map.primitive.ImmutableObject<name>Map;
import org.eclipse.collections.impl.factory.primitive.<name>ObjectMaps;
import org.eclipse.collections.impl.factory.primitive.Object<name>Maps;
import org.eclipse.collections.impl.map.mutable.primitive.Object<name>HashMap;
import org.eclipse.collections.impl.map.mutable.primitive.<name>ObjectHashMap;
import org.eclipse.collections.impl.map.primitive.AbstractObject<name>MapTestCase;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;
/**
* Abstract JUnit test for {@link ImmutableObject<name>HashMap}.
* This file was automatically generated from template file abstractImmutableObjectPrimitiveMapTestCase.stg.
*/
public abstract class AbstractImmutableObject<name>MapTestCase extends AbstractObject<name>MapTestCase
{
@Override
protected abstract ImmutableObject<name>Map\<String> classUnderTest();
@Override
protected \<T> ImmutableObject<name>Map\<T> newWithKeysValues(T key1, <type> value1)
{
return Object<name>HashMap.newWithKeysValues(key1, value1).toImmutable();
}
@Override
protected \<T> ImmutableObject<name>Map\<T> newWithKeysValues(T key1, <type> value1, T key2, <type> value2)
{
return Object<name>HashMap.newWithKeysValues(key1, value1, key2, value2).toImmutable();
}
@Override
protected \<T> ImmutableObject<name>Map\<T> newWithKeysValues(T key1, <type> value1, T key2, <type> value2, T key3, <type> value3)
{
return Object<name>HashMap.newWithKeysValues(key1, value1, key2, value2, key3, value3).toImmutable();
}
@Override
protected \<T> ImmutableObject<name>Map\<T> newWithKeysValues(T key1, <type> value1, T key2, <type> value2, T key3, <type> value3, T key4, <type> value4)
{
return Object<name>HashMap.newWithKeysValues(key1, value1, key2, value2, key3, value3, key4, value4).toImmutable();
}
@Override
protected \<T> ImmutableObject<name>Map\<T> getEmptyMap()
{
return new Object<name>HashMap\<T>().toImmutable();
}
@Override
@Test
public void toImmutable()
{
super.toImmutable();
ImmutableObject<name>Map\<String> map = this.classUnderTest();
Assert.assertSame(map, map.toImmutable());
}
@Override
@Test
public void keySet()
{
super.keySet();
Verify.assertThrows(UnsupportedOperationException.class, () -> this.classUnderTest().keySet().remove("0"));
}
@Override
public void values()
{
super.values();
Verify.assertThrows(UnsupportedOperationException.class, () -> this.classUnderTest().values().remove(<(literal.(type))("0")>));
}
@Test
public void flipUniqueValues()
{
Assert.assertEquals(<name>ObjectMaps.immutable.empty(), Object<name>Maps.immutable.empty().flipUniqueValues());
Verify.assertInstanceOf(Immutable<name>ObjectEmptyMap.class, Object<name>Maps.immutable.empty().flipUniqueValues());
Assert.assertEquals(<name>ObjectMaps.immutable.with(<(literal.(type))("2")>, "1"), this.newWithKeysValues("1", <(literal.(type))("2")>).flipUniqueValues());
Assert.assertEquals(
<name>ObjectHashMap.newWithKeysValues(<(literal.(type))("2")>, "1", <(literal.(type))("3")>, "2").toImmutable(),
this.newWithKeysValues("1", <(literal.(type))("2")>, "2", <(literal.(type))("3")>).flipUniqueValues());
Verify.assertThrows(IllegalStateException.class, () -> this.newWithKeysValues("1", <(literal.(type))("1")>, "2", <(literal.(type))("1")>).flipUniqueValues());
}
}
>>