test_class.file: smart-hadoop-support/smart-hadoop/src/test/java/org/smartdata/hdfs/action/TestTruncate0Action.java
test_class.identifier: TestTruncate0Action
test_class.superclass: extends MiniClusterHarness
test_case.body: @Test
    public void testSetFileLen() throws IOException, InterruptedException {
      final String srcPath = "/test";
      final String file = "file";
  
      dfs.mkdirs(new Path(srcPath));
      FSDataOutputStream out = dfs.create(new Path(srcPath + "/" + file));
  
      for (int i = 0; i < 50; i++) {
        out.writeByte(1);
      }
  
      out.close();
  
      dfs.setXAttr(new Path(srcPath + "/" + file), "user.coldloc", "test".getBytes(),
              EnumSet.of(XAttrSetFlag.CREATE, XAttrSetFlag.REPLACE));
      FileStatus oldFileStatus = dfs.getFileStatus(new Path(srcPath + "/" + file));
      Map<String, byte[]> oldXAttrs = dfs.getXAttrs(new Path(srcPath + "/" + file));
  
      Truncate0Action setLen2ZeroAction = new Truncate0Action();
      setLen2ZeroAction.setDfsClient(dfsClient);
      setLen2ZeroAction.setContext(smartContext);
      Map<String, String> args = new HashMap<>();
      args.put(Truncate0Action.FILE_PATH, srcPath + "/" + file);
  
      setLen2ZeroAction.init(args);
      setLen2ZeroAction.run();
      Assert.assertTrue(setLen2ZeroAction.getExpectedAfterRun());
  
      FileStatus newFileStatus = dfs.getFileStatus(new Path(srcPath + "/" + file));
      Map<String, byte[]> newXAttrs = dfs.getXAttrs(new Path(srcPath + "/" + file));
  
      Assert.assertTrue(newFileStatus.getLen()==0);
      Assert.assertTrue(oldFileStatus.getOwner().equals(newFileStatus.getOwner()));
      Assert.assertTrue(oldFileStatus.getGroup().equals(newFileStatus.getGroup()));
      Assert.assertTrue(oldFileStatus.getPermission().equals(newFileStatus.getPermission()));
      Assert.assertTrue(oldFileStatus.getReplication()==newFileStatus.getReplication());
      //Assert.assertTrue(oldFileStatus.getAccessTime()==newFileStatus.getAccessTime());
      //Assert.assertTrue(oldFileStatus.getModificationTime()==newFileStatus.getModificationTime());
      Assert.assertTrue(oldXAttrs.size()==newXAttrs.size());
      for(Map.Entry<String, byte[]> oldXAttr : oldXAttrs.entrySet()){
        Assert.assertTrue(Arrays.equals(oldXAttr.getValue(),newXAttrs.get(oldXAttr.getKey())));
      }
    }
test_case.class_method_signature: TestTruncate0Action.testSetFileLen()
test_case.full_signature: @Test public void testSetFileLen()
test_case.identifier: testSetFileLen
test_case.invocations: mkdirs create writeByte close setXAttr getBytes of getFileStatus getXAttrs setDfsClient setContext put init run assertTrue getExpectedAfterRun getFileStatus getXAttrs assertTrue getLen assertTrue equals getOwner getOwner assertTrue equals getGroup getGroup assertTrue equals getPermission getPermission assertTrue getReplication getReplication assertTrue size size entrySet assertTrue equals getValue get getKey
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSetFileLen()
focal_class.declarator: LOG = LoggerFactory.getLogger(TruncateAction.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(TruncateAction.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: srcPath
focal_class.modifier: private
focal_class.original_string: private String srcPath;
focal_class.type: String
focal_class.var_name: srcPath
focal_class.file: smart-hadoop-support/smart-hadoop/src/main/java/org/smartdata/hdfs/action/Truncate0Action.java
focal_class.identifier: Truncate0Action
focal_class.class_method_signature: Truncate0Action.init(Map<String, String> args)
focal_class.full_signature: @Override public void init(Map<String, String> args)
focal_class.identifier: init
focal_class.modifiers: @Override public
focal_class.parameters: (Map<String, String> args)
focal_class.return: void
focal_class.signature: void init(Map<String, String> args)
focal_class.class_method_signature: Truncate0Action.execute()
focal_class.full_signature: @Override protected void execute()
focal_class.identifier: execute
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void execute()
focal_class.class_method_signature: Truncate0Action.setLen2Zero(String srcPath)
focal_class.full_signature: private boolean setLen2Zero(String srcPath)
focal_class.identifier: setLen2Zero
focal_class.modifiers: private
focal_class.parameters: (String srcPath)
focal_class.return: boolean
focal_class.signature: boolean setLen2Zero(String srcPath)
focal_class.class_method_signature: Truncate0Action.setLen2Zero(DFSClient client, String src)
focal_class.full_signature: private boolean setLen2Zero(DFSClient client, String src)
focal_class.identifier: setLen2Zero
focal_class.modifiers: private
focal_class.parameters: (DFSClient client, String src)
focal_class.return: boolean
focal_class.signature: boolean setLen2Zero(DFSClient client, String src)
focal_class.class_method_signature: Truncate0Action.setLen2Zero(DistributedFileSystem fileSystem, String src)
focal_class.full_signature: private boolean setLen2Zero(DistributedFileSystem fileSystem, String src)
focal_class.identifier: setLen2Zero
focal_class.modifiers: private
focal_class.parameters: (DistributedFileSystem fileSystem, String src)
focal_class.return: boolean
focal_class.signature: boolean setLen2Zero(DistributedFileSystem fileSystem, String src)
focal_class.superclass: extends HdfsAction
focal_method.body: @Override
    public void init(Map<String, String> args) {
      super.init(args);
      srcPath = args.get(FILE_PATH);
    }
focal_method.class_method_signature: Truncate0Action.init(Map<String, String> args)
focal_method.full_signature: @Override public void init(Map<String, String> args)
focal_method.identifier: init
focal_method.invocations: init get
focal_method.modifiers: @Override public
focal_method.parameters: (Map<String, String> args)
focal_method.return: void
focal_method.signature: void init(Map<String, String> args)