Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.model.core.event

File AbstractEventTest.java

 

Code metrics

0
7
6
3
54
43
6
0.86
1.17
2
1

Classes

Class Line # Actions
AbstractEventTest 15 5 3
1.0100%
AbstractEventTest.Category 22 0 0
-1.0 -
AbstractEventTest.Event 30 2 3
0.660%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    package io.sunshower.model.core.event;
2   
3    import static org.hamcrest.core.Is.is;
4    import static org.junit.Assert.*;
5   
6    import io.sunshower.common.Identifier;
7    import io.sunshower.test.common.SerializationAware;
8    import io.sunshower.test.common.SerializationTestCase;
9    import javax.xml.bind.annotation.*;
10    import org.junit.jupiter.api.Test;
11    import org.junit.platform.runner.JUnitPlatform;
12    import org.junit.runner.RunWith;
13   
14    @RunWith(JUnitPlatform.class)
 
15    public class AbstractEventTest extends SerializationTestCase {
16   
 
17  2 toggle public AbstractEventTest() {
18  2 super(SerializationAware.Format.JSON, Event.class, Category.class);
19    }
20   
21    @XmlEnum
 
22    public enum Category {
23    @XmlEnumValue("fst")
24    Fst,
25    @XmlEnumValue("snd")
26    Snd
27    }
28   
29    @XmlRootElement(name = "e")
 
30    public static class Event extends AbstractEvent {
31   
 
32  2 toggle public Event() {}
33   
 
34  2 toggle public Event(String type, String category) {
35  2 super(type, category);
36    }
37   
 
38  0 toggle public Event(Identifier id, String type, String category) {
39  0 super(id, type, category);
40    }
41    }
42   
 
43  1 toggle @Test
44    public void ensureWritingEventProducesExpectedResults() {
45  1 Event whatever = copy(new Event(Category.Fst.toString(), "whatever"));
46  1 assertThat(whatever.getType(), is(Category.Fst.toString()));
47    }
48   
 
49  1 toggle @Test
50    public void ensureWritingEventCopiesCategory() {
51  1 Event whatever = copy(new Event(Category.Fst.toString(), "whatever"));
52  1 assertThat(whatever.getCategory(), is("whatever"));
53    }
54    }