Gridarta Editor
FilterConfigDecoderTest.java
Go to the documentation of this file.
1 package net.sf.gridarta.model.filter;
2 
3 import java.util.Arrays;
4 import java.util.Collections;
7 import org.jetbrains.annotations.NotNull;
8 import org.junit.Assert;
9 import org.junit.Test;
10 
14 @SuppressWarnings("JavaDoc")
16 
17  @NotNull
18  private static final NamedGameObjectMatcher GAME_OBJECT_MATCHER1 = new NamedGameObjectMatcher(1, "i1", "f1", true, null, new TypeNrsGameObjectMatcher(1));
19 
20  @NotNull
21  private static final NamedGameObjectMatcher GAME_OBJECT_MATCHER2 = new NamedGameObjectMatcher(2, "i2", "f2", true, null, new TypeNrsGameObjectMatcher(2));
22 
23  @Test
24  public void decodeNamedFilter1() {
25  check(new NamedFilter(Collections.emptyList()).createConfig(), "");
26  check(new NamedFilter(Collections.emptyList()).createConfig(), "(enabled)");
27  check(new NamedFilter(Collections.emptyList()).createConfig(), "(enabled,inverted)");
28  check(new NamedFilter(Collections.emptyList()).createConfig(), "(inverted)");
29  }
30 
31  @Test
33  //check(new NamedGameObjectMatcherFilter(GAME_OBJECT_MATCHER1).createConfig(), "");
34  check(new NamedGameObjectMatcherFilter(GAME_OBJECT_MATCHER1).createConfig(), "(enabled)");
35  }
36 
37  @Test
38  public void decodeSubFilterConfig1() {
39  check(new NamedFilter(Collections.singleton(GAME_OBJECT_MATCHER1)).createConfig(), "");
40  check(new NamedFilter(Collections.singleton(GAME_OBJECT_MATCHER1)).createConfig(), "(enabled)");
41  check(new NamedFilter(Collections.singleton(GAME_OBJECT_MATCHER1)).createConfig(), "(enabled,inverted)");
42  check(new NamedFilter(Collections.singleton(GAME_OBJECT_MATCHER1)).createConfig(), "(inverted)");
43  }
44 
45  @Test
46  public void decodeSubFilterConfig2() {
47  check(new NamedFilter(Arrays.asList(GAME_OBJECT_MATCHER1, GAME_OBJECT_MATCHER2)).createConfig(), "");
48  check(new NamedFilter(Arrays.asList(GAME_OBJECT_MATCHER1, GAME_OBJECT_MATCHER2)).createConfig(), "(f1=(enabled))");
49  check(new NamedFilter(Arrays.asList(GAME_OBJECT_MATCHER1, GAME_OBJECT_MATCHER2)).createConfig(), "(f1=(enabled),f2=(enabled))");
50  check(new NamedFilter(Arrays.asList(GAME_OBJECT_MATCHER1, GAME_OBJECT_MATCHER2)).createConfig(), "(f2=(enabled))");
51  }
52 
53  private void check(@NotNull final FilterConfig<?, ?> config, @NotNull final String string) {
54  Assert.assertTrue(new FilterConfigDecoder().decode(string, config));
55  Assert.assertEquals(string, new FilterConfigEncoder().encode(config));
56  }
57 
58 }
A Filter that aggregates named filters.
This package contains classes related to matching GameObjects, so called GameObjectMatchers.
A Filter which filters according to a net.sf.gridarta.model.match.NamedGameObjectMatcher.
Decorates an arbitrary GameObjectMatcher with a localized name that is suitable for the user interfac...
Converts FilterConfig into string representation.
void check(@NotNull final FilterConfig<?, ?> config, @NotNull final String string)
Base package of all Gridarta classes.
An GameObjectMatcher matching certain archetype types.
Converts a string into a FilterConfig.