You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/test/com/platform/test/MapTest.java

73 lines
1.9 KiB

package com.platform.test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import com.platform.entities.CheckoutEntity;
public class MapTest {
@Test
public void TestRemove(){
Map<String, CheckoutEntity> map = new HashMap<String, CheckoutEntity>();
CheckoutEntity t = new CheckoutEntity();
t.setId(21);
map.put("12", t);
CheckoutEntity tmp = map.remove("12");
System.out.println(tmp.getId());
}
@Test
public void testKey() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("/home/gfs_ftp_point/boliang/oracle/320312_97/3-/pengbl_test2/sql_data/320305_34/320312_97/", 2);
map.put("/home/gfs_ftp_point/boliang/oracle/320312_97/3/-/pengbl_test2/sql_data/320305_34/320312_97/", 3);
System.out.println(map.get("/home/gfs_ftp_point/boliang/oracle/320312_97/3-/pengbl_test2/sql_data/320305_34/320312_97/"));
}
@Test
public void testRemove() {
List<Brick> li = new ArrayList<Brick>();
Brick brick= new Brick("192", "/h2");
li.add(brick);
Brick brick2= new Brick("193", "/h2");
li.add(brick2);
Map<String, Object> map = new HashMap<String, Object>();
for (Brick b : li) {
map.put(b.getIp(), b);
}
map.remove("193");
System.out.println(map.size());
System.out.println(li.size());
li.remove(0);
System.out.println(map.size());
System.out.println(li.size());
}
@Test
public void testMapPut() {
Map<String, List> errmap = new HashMap<String, List>();
List<String> errArea = new ArrayList<String>();
errArea.add("aaa");
if (errArea.size() > 0) {
errmap.put("err", errArea);
}
List<String> errFile = new ArrayList<String>();
// errFile.add("file");
if (errFile.size() > 0) {
if (errmap.containsKey("err")) {
errFile.addAll(errmap.get("err"));
}
errmap.put("err", errFile);
}
System.err.println(errmap);
}
}