// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
//     public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
//         generator.generateActon(sb, this, subject);
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
//     private String adapterId;
//     private String className;
//     private String value;
// 
//     public Data(String adapterId, String className) {
//         this.adapterId = adapterId;
//         this.className = className;
//     }
//     public Data(String adapterId, String className, String value) {
//         this.adapterId = adapterId;
//         this.className = className;
//         this.value = value;
//     }
// 
//     public String getAdapterId() {
//         return adapterId;
//     }
// 
//     public String getClassName() {
//         return className;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateSubject(sb, this);
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
//     private String group = null;
//     private Subject subject;
//     private Action action;
//     private String description;
//     private long time;
// 
//     public RecordingEvent(String group, Subject subject, Action action) {
//         this.group = group;
//         this.subject = subject;
//         this.action = action;
//     }
// 
//     public RecordingEvent(Subject subject, Action action, String description) {
//         this.subject = subject;
//         this.action = action;
//         this.description = description;
//     }
// 
//     public Subject getSubject() {
//         return subject;
//     }
// 
//     public Action getAction() {
//         return action;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public String getGroup() {
//         return group;
//     }
// 
//     public void setGroup(String group) {
//         this.group = group;
//     }
// 
//     public long getTime() {
//         return time;
//     }
// 
//     public void setTime(long time) {
//         this.time = time;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateEvent(sb, this);
//     }
// 
//     @Override
//     public String toString() {
//         return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
//                 (description==null?"":description)+"]";
//     }
// 
//     public static RecordingEvent fromString(String str) {
//         String tmp = str.substring(7, str.length()-1);
//         String arr[] = tmp.split("[,]");
// 
//         String timeStr = arr[0];
//         String group = arr[1];
//         String subjectStr = arr[2];
//         String actionStr = arr[3];
//         String description = arr.length == 5 ? arr[4] : null;
//         RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
// 
//         event.setTime(Long.parseLong(timeStr));
// 
//         if (group.length() > 0) {
//             event.setGroup(group);
//         }
// 
//         return event;
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
//     private String id;
// 
//     public View(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateSubject(sb, this);
//     }
// }


import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;
package com.vpedak.testrecorder.core.events;


public class RecordingEventTest {

    @Test
    public void testSerialization() {
        RecordingEvent event1 = new RecordingEvent(new Data("adapterId", "className", "value"), new ClickAction(), "description text");
        Assert.assertEquals("event=[,data=adapterId#className#value,action=click,description text]", event1.toString());

        RecordingEvent event2 = new RecordingEvent(new View("viewId"), new ClickAction(), "description text");
        event2.setGroup("grp");
        Assert.assertEquals("event=[grp,view=viewId,action=click,description text]", event2.toString());

        RecordingEvent event3 = new RecordingEvent("grp", new View("viewId"), new ClickAction());
        Assert.assertEquals("event=[grp,view=viewId,action=click,]", event3.toString());
    }

    @Test
    public void testDeserialization() {
        RecordingEvent event1 = RecordingEvent.fromString("event=[,data=adapterId#className#value,action=click,description text]");
        Assert.assertEquals("description text", event1.getDescription());
        Assert.assertTrue(event1.getSubject() instanceof Data);
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/ClickAction.java
// public class ClickAction extends Action {
//     public void accept(StringBuilder sb, TestGenerator generator, Subject subject){
//         generator.generateActon(sb, this, subject);
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/Data.java
// public class Data extends Subject {
//     private String adapterId;
//     private String className;
//     private String value;
// 
//     public Data(String adapterId, String className) {
//         this.adapterId = adapterId;
//         this.className = className;
//     }
//     public Data(String adapterId, String className, String value) {
//         this.adapterId = adapterId;
//         this.className = className;
//         this.value = value;
//     }
// 
//     public String getAdapterId() {
//         return adapterId;
//     }
// 
//     public String getClassName() {
//         return className;
//     }
// 
//     public String getValue() {
//         return value;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateSubject(sb, this);
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/RecordingEvent.java
// public class RecordingEvent {
//     private String group = null;
//     private Subject subject;
//     private Action action;
//     private String description;
//     private long time;
// 
//     public RecordingEvent(String group, Subject subject, Action action) {
//         this.group = group;
//         this.subject = subject;
//         this.action = action;
//     }
// 
//     public RecordingEvent(Subject subject, Action action, String description) {
//         this.subject = subject;
//         this.action = action;
//         this.description = description;
//     }
// 
//     public Subject getSubject() {
//         return subject;
//     }
// 
//     public Action getAction() {
//         return action;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public String getGroup() {
//         return group;
//     }
// 
//     public void setGroup(String group) {
//         this.group = group;
//     }
// 
//     public long getTime() {
//         return time;
//     }
// 
//     public void setTime(long time) {
//         this.time = time;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateEvent(sb, this);
//     }
// 
//     @Override
//     public String toString() {
//         return "event=["+time+","+(getGroup()==null?"":getGroup())+","+subject.toString()+","+action.toString()+"," +
//                 (description==null?"":description)+"]";
//     }
// 
//     public static RecordingEvent fromString(String str) {
//         String tmp = str.substring(7, str.length()-1);
//         String arr[] = tmp.split("[,]");
// 
//         String timeStr = arr[0];
//         String group = arr[1];
//         String subjectStr = arr[2];
//         String actionStr = arr[3];
//         String description = arr.length == 5 ? arr[4] : null;
//         RecordingEvent event = new RecordingEvent(Subject.fromString(subjectStr), Action.fromString(actionStr), description);
// 
//         event.setTime(Long.parseLong(timeStr));
// 
//         if (group.length() > 0) {
//             event.setGroup(group);
//         }
// 
//         return event;
//     }
// }
// 
// Path: RecordingLib/src/com/vpedak/testsrecorder/core/events/View.java
// public class View extends Subject {
//     private String id;
// 
//     public View(String id) {
//         this.id = id;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public void accept(StringBuilder sb, TestGenerator generator){
//         generator.generateSubject(sb, this);
//     }
// }


// Path: RecordingLib/test/com/vpedak/testrecorder/core/events/RecordingEventTest.java
import com.vpedak.testsrecorder.core.events.ClickAction;
import com.vpedak.testsrecorder.core.events.Data;
import com.vpedak.testsrecorder.core.events.RecordingEvent;
import com.vpedak.testsrecorder.core.events.View;
import org.junit.Assert;
import org.junit.Test;

package com.vpedak.testrecorder.core.events;


public class RecordingEventTest {

    @Test
    public void testSerialization() {
        RecordingEvent event1 = new RecordingEvent(new Data("adapterId", "className", "value"), new ClickAction(), "description text");
        Assert.assertEquals("event=[,data=adapterId#className#value,action=click,description text]", event1.toString());

        RecordingEvent event2 = new RecordingEvent(new View("viewId"), new ClickAction(), "description text");
        event2.setGroup("grp");
        Assert.assertEquals("event=[grp,view=viewId,action=click,description text]", event2.toString());

        RecordingEvent event3 = new RecordingEvent("grp", new View("viewId"), new ClickAction());
        Assert.assertEquals("event=[grp,view=viewId,action=click,]", event3.toString());
    }

    @Test
    public void testDeserialization() {
        RecordingEvent event1 = RecordingEvent.fromString("event=[,data=adapterId#className#value,action=click,description text]");
        Assert.assertEquals("description text", event1.getDescription());
        Assert.assertTrue(event1.getSubject() instanceof Data);
        Assert.assertEquals("adapterId", ((Data)event1.getSubject()).getAdapterId());