ConfigurationObject implements IObject { @Override public Object getValue(final IFieldName name) throws ReadValueException, InvalidArgumentException { if (null == name) { throw new InvalidArgumentException("Name parameter should not be null."); } try { if (canonizedBody.containsKey(name)) { return canonizedBody.get(name); } Object canonicalValue = IOC.resolve( IOC.resolve(IOC.getKeyForKeyStorage(), "resolve key for configuration object"), name, body.get(name) ); if (null != canonicalValue) { canonizedBody.put(name, canonicalValue); } return canonicalValue; } catch (Throwable e) { throw new ReadValueException("Can't read value for current field name", e); } } ConfigurationObject(final String body);  ConfigurationObject(final Map<IFieldName, Object> objectEntries);  ConfigurationObject(); @Override Object getValue(final IFieldName name); @Override void setValue(final IFieldName name, final Object value); @Override void deleteField(final IFieldName name); @Override T serialize(); @Override Iterator<Map.Entry<IFieldName, Object>> iterator(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void checkCreationAndResolutionSomeFields() throws Exception { ConfigurationObject co = new ConfigurationObject(this.configString); List<IObject> in_getIntValue = (List<IObject>) ((IObject)co.getValue(new FieldName("wrapper"))).getValue(new FieldName("in_getIntValue")); assertEquals(in_getIntValue.get(0).getValue(new FieldName("name")), "wds_getter_strategy"); assertEquals(((List)in_getIntValue.get(0).getValue(new FieldName("args"))).get(0), "message/IntValue"); List<List<IObject>> out_setIntValue = (List<List<IObject>>) ((IObject)co.getValue(new FieldName("wrapper"))).getValue(new FieldName("out_setIntValue")); assertEquals(out_setIntValue.get(0).get(0).getValue(new FieldName("name")), "wds_target_strategy"); assertEquals(((List)out_setIntValue.get(0).get(0).getValue(new FieldName("args"))).get(0), "local/value"); assertEquals(((List)out_setIntValue.get(0).get(0).getValue(new FieldName("args"))).get(1), "response/IntValue"); List<List<IObject>> out_setIObject = (List<List<IObject>>) ((IObject)co.getValue(new FieldName("wrapper"))).getValue(new FieldName("out_setIObject")); assertEquals(out_setIObject.get(0).get(0).getValue(new FieldName("name")), "wds_target_strategy"); assertEquals(((List)out_setIObject.get(0).get(0).getValue(new FieldName("args"))).get(0), "local/value"); assertEquals(((List)out_setIObject.get(0).get(0).getValue(new FieldName("args"))).get(1), "response/IObject"); List<IObject> in_getStringValue = (List<IObject>) ((IObject)co.getValue(new FieldName("wrapper"))).getValue(new FieldName("in_getStringValue")); assertEquals(in_getStringValue.get(0).getValue(new FieldName("name")), "wds_getter_strategy"); assertEquals(((List)in_getStringValue.get(0).getValue(new FieldName("args"))).get(0), "message/StringValue"); }
@Test (expected = InvalidArgumentException.class) public void checkExceptionOnNullArgInGetValueMethod() throws Exception { ConfigurationObject co = new ConfigurationObject(this.configString); co.getValue(null); fail(); }
@Test (expected = ReadValueException.class) public void checkReadValueExceptionOnUseGetValueMethod() throws Exception { Object scopeId = ScopeProvider.createScope(null); IScope oldScope = ScopeProvider.getCurrentScope(); ScopeProvider.setCurrentScope(ScopeProvider.getScope(scopeId)); ConfigurationObject co = new ConfigurationObject(this.configString); co.getValue(new FieldName("in_getIntValue")); ScopeProvider.setCurrentScope(oldScope); fail(); }