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

106 lines
2.8 KiB

package com.platform.test;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
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<HashMap<String, Object>> errFile = new ArrayList<HashMap<String, Object>>();
List<HashMap<String, Object>> rowErr = new ArrayList<HashMap<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "test");
map.put("value", "te");
errFile.add((HashMap<String, Object>) map);
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("name", "test2");
map2.put("value", "te2");
rowErr.add((HashMap<String, Object>) map2);
if (rowErr.size() > 0) {
errmap.put("err", rowErr);
}
// errFile.add("file");
if (errFile.size() > 0) {
if (errmap.containsKey("err")) {
errFile.addAll(errmap.get("err"));
}
errmap.put("err", errFile);
}
System.err.println(errmap);
}
@Test
public void test2() {
Map<String, CheckoutEntity> map = new HashMap<String, CheckoutEntity>();
CheckoutEntity t = new CheckoutEntity();
t.setId(21);
map.put("12", t);
map.put("13", t);
map.put("14", t);
Set<String> keys = map.keySet();
String tmpKey = "";
if (keys.size() > 0) {
tmpKey = keys.iterator().next();
System.out.println(tmpKey);
}
CheckoutEntity data = map.get(tmpKey);
map.remove(tmpKey);
if (null != data) {
System.err.println(data.getId());
}
}
}