17:48, EET
August 20, 2014
14:11, EET
April 3, 2012
Hi,
It is primarily intended as return value from TypeDictionary, i.e. constructing it is somewhat SDK internals. However it should be doable manually as well, but the current constructors are quite ugly to use, depending on what kind of fields your Structure does have (e.g. are they known/standard types?) and how exactly your code interacts with it?
Do you need the encoded binary format or is interacting with the DynamicStructure object enough?
Do you need a real DynamicStructure, or could you just mock it?
If a mock is enough, you could use e.g. https://site.mockito.org/, and for example
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
//note that I only added static imports for the forum in this example, it will have normal imports as well
@Test
public void example() throws Exception {
DynamicStructure ds = mock(DynamicStructure.class);
// You need to mock all return values you need, see mockito manuals for more info
when(ds.get("AA")).thenReturn("TESTVALUE");
// Simulating your code interacting with the DynamicStructure instance
assertEquals("TESTVALUE", ds.get("AA")); //your code would get the "TESTVALUE" if it asked ds.get("AA")
ds.set("Name", "Value"); // e.g. your code could call this
verify(ds).set("Name", "Value"); // verifies that your code did call this
}
P.S.
Do note that multidimensional fields are not possible (as they were added in UA 1.04, which the current release version does not yet support).
17:11, EET
August 20, 2014
Hi Bjarne,
thanks for the example. Yes i only need to handle the DynamicStructure. Our code converts ExtensionObjects into JSON in a generic way and vise versa. So i need to create a DynamicStructure and pass it to the converter Method and look at the json that is created. Your approach looks nice i will see how far i will come with that..
Thanks.
Ibrahim
Most Users Ever Online: 1919
Currently Online:
59 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1