private static Map<String,Object> instances = null;
public static Map<String,Object> getInstances() {
if(instances==null){
instances = new HashMap<>();
}else
return instances;
}
@Before
public void createCoupons(){
instances.put("coupon1",companyServiceTesting.createCompanyCoupon((Company)instances.get("company1"),callForCoupon(),"Travelling low prices","FamilyTravelling",
23,765475475,"C://ProgramFiles",35.8, CouponType.TRAVELING, CouponSystemDate.dateFormat(2017,12,12)
,CouponSystemDate.dateFormat(2019,12,12)));
...
@Before
public void createCoupons(){
Object obj = companyServiceTesting.createCompanyCoupon((Company)instances.get("company1"),callForCoupon(),"Travelling low prices","FamilyTravelling",
23,765475475,"C://ProgramFiles",35.8, CouponType.TRAVELING, CouponSystemDate.dateFormat(2017,12,12)
,CouponSystemDate.dateFormat(2019,12,12))
instances.put("coupon1",obj);
...
@AfterClass
public static void checkTheSetedObjects(){
System.out.println("Checking the setted data! ");
Map<String,Object> instances = getInstances();
Iterator<Map.Entry<String,Object>> iterator = instances.entrySet().iterator();
while (iterator.hasNext()){
Object value = iterator.next().getValue();
System.out.println("Iterated value: "+value);
}
}
System.out.println("Checking the setted data! ");
Map<String,Object> instances = getInstances();
for(Map.Entry<String,Object> entry :instances.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
System.out.println("Iterated key: "+key + " "+"Iterated value: "+value);
for (Object key : instance.keySet())
if (что то)
instance.remove(key);
for(Iterator<Map.Entry<String, CompanyObject>> it = instance.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, CompanyObject> entry = it.next();
if(что то) {
it.remove();
}
}
for (Object obj : new ArrayList<Object>(instance.keySet()))
if (что то)
instance.remove(key);