package tachyon.master;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.junit.Test;

import java.io.IOException;
import java.util.List;

/**
 * Unit Test for EditLogOperation
 */
public class EditLogOperationTest {
  private static final String CREATE_DEPENDENCY_TYPE = "{\"type\":\"CREATE_DEPENDENCY\"," +
      "\"parameters\":{\"parents\":[],\"commandPrefix\":\"fake command\"," +
      "\"dependencyId\":1,\"frameworkVersion\":\"0.3\",\"data\":[\"AAAAAAAAAAAAAA==\"]," +
      "\"children\":[251,252,253,254,255,256,257,258,259,260]," +
      "\"comment\":\"BasicCheckpoint Dependency\",\"creationTimeMs\":1409349750338," +
      "\"dependencyType\":\"Narrow\",\"framework\":\"Tachyon Examples\"}}";

  private static final ObjectMapper OBJECT_MAPPER = JsonObject.createObjectMapper();

  // Tests for CREATE_DEPENDENCY operation
  @Test
  public void createDependencyTest() throws IOException {
    EditLogOperation editLogOperation = OBJECT_MAPPER.readValue(CREATE_DEPENDENCY_TYPE.getBytes(),
        EditLogOperation.class);

    // get all parameters for "CREATE_DEPENDENCY"
    editLogOperation.get("parents", new TypeReference<List<Integer>>() {});
    editLogOperation.get("children", new TypeReference<List<Integer>>() {});
    editLogOperation.getString("commandPrefix");
    editLogOperation.getByteBufferList("data");
    editLogOperation.getString("comment");
    editLogOperation.getString("framework");
    editLogOperation.getString("frameworkVersion");
    editLogOperation.get("dependencyType", DependencyType.class);
    editLogOperation.getInt("dependencyId");
    editLogOperation.getLong("creationTimeMs");
  }

}

@@ -14,24 +14,104 @@
 on.master;%0A%0A
+import java.io.IOException;%0Aimport java.nio.ByteBuffer;%0Aimport java.util.List;%0A%0A
 import com.f
@@ -216,72 +216,98 @@
 ort 
-org.
 junit.
-Tes
+framework.Asser
 t;%0A
-%0A
 import 
-java.io.IOException;%0Aimport java.util.Li
+org.apache.commons.codec.binary.Base64;%0Aimport org.junit.Te
 st;%0A
@@ -513,16 +513,21 @@
 ents%5C%22:%5B
+1,2,3
 %5D,%5C%22comm
@@ -675,47 +675,15 @@
 %5C%22:%5B
-251,252,253,254,255,256,257,258,259,260
+4,5,6,7
 %5D,%22 
@@ -709,34 +709,20 @@
 %22:%5C%22
-BasicCheckpoint Dependency
+Comment Test
 %5C%22,%5C
@@ -1211,24 +1211,48 @@
 ENDENCY%22%0A   
+ List%3CInteger%3E parents =
  editLogOper
@@ -1307,32 +1307,102 @@
 ger%3E%3E() %7B%7D);%0A   
+ Assert.assertEquals(3, parents.size());%0A%0A    List%3CInteger%3E children =
  editLogOperatio
@@ -1467,397 +1467,1224 @@
     
-editLogOperation.getString(%22commandPrefix%22);%0A    editLogOperation.getByteBufferList(%22data%22);%0A    editLogOperation.getString(%22comment%22);%0A    editLogOperation.getString(%22framework%22);%0A    editLogOperation.getString(%22frameworkVersion%22);%0A    editLogOperation.get(%22dependencyType%22, DependencyType.class);%0A    editLogOperation.getInt(%22dependencyId%22);%0A    editLogOperation.getLong(%22creationTimeMs%22
+Assert.assertEquals(4, children.size());%0A%0A    String commandPrefix = editLogOperation.getString(%22commandPrefix%22);%0A    Assert.assertEquals(%22fake command%22, commandPrefix);%0A%0A    List%3CByteBuffer%3E data = editLogOperation.getByteBufferList(%22data%22);%0A    Assert.assertEquals(1, data.size());%0A    String decodedBase64 = new String(data.get(0).array(), %22UTF-8%22);%0A    Assert.assertEquals(new String (Base64.decodeBase64(%22AAAAAAAAAAAAAA==%22)), decodedBase64);%0A%0A    String comment = editLogOperation.getString(%22comment%22);%0A    Assert.assertEquals(%22Comment Test%22, comment);%0A%0A    String framework = editLogOperation.getString(%22framework%22);%0A    Assert.assertEquals(%22Tachyon Examples%22, framework);%0A%0A    String frameworkVersion = editLogOperation.getString(%22frameworkVersion%22);%0A    Assert.assertEquals(%220.3%22, frameworkVersion);%0A%0A    DependencyType dependencyType = editLogOperation.get(%22dependencyType%22, DependencyType.class);%0A    Assert.assertEquals(DependencyType.Narrow, dependencyType);%0A%0A    Integer depId = editLogOperation.getInt(%22dependencyId%22);%0A    Assert.assertEquals(1, depId.intValue());%0A%0A    Long creationTimeMs = editLogOperation.getLong(%22creationTimeMs%22);%0A    Assert.assertEquals(1409349750338L, creationTimeMs.longValue()
 );%0A 

Add the assert tests to verify content parsed.