### Question:
DynamicObjectBuilder { @Deprecated public <INTERFACE, INSTANCE extends INTERFACE> INTERFACE advertiseMethods(final Class<INTERFACE> interfaceClass, final INSTANCE instance) { return this.advertiseMethods(QiSerializer.getDefault(), interfaceClass, instance); } DynamicObjectBuilder(); void advertiseMethod(String methodSignature, QiService service, String description); void advertiseSignal(String signalSignature); @Deprecated void advertiseProperty(String name, Class<?> propertyBase); void advertiseProperty(String name, Property<T> property); void setThreadingModel(ObjectThreadingModel threadModel); AnyObject object(); @Deprecated INTERFACE advertiseMethods(final Class<INTERFACE> interfaceClass,
            final INSTANCE instance); INTERFACE advertiseMethods(final QiSerializer serializer,
                                                                              final Class<INTERFACE> interfaceClass,
                                                                              final INSTANCE instance);  }### Answer:
@Test public void advertiseMethodsReturnsInstance() { String instance = new String("toto"); String output = (String) builder.advertiseMethods(QiSerializer.getDefault(), Serializable.class, instance); Assert.assertSame(instance, output); }
@Test public void advertiseMethodsWithStruct() { AClass anInstance = new AClass(); QiSerializer serializer = new QiSerializer(); DynamicObjectBuilder objectBuilder = new DynamicObjectBuilder(); AnInterface sameInstance = objectBuilder.advertiseMethods(serializer, AnInterface.class, anInstance); Assert.assertSame(sameInstance, anInstance); AStruct struct = sameInstance.returnAStruct(); AStruct initialStruct = anInstance.returnAStruct(); Assert.assertEquals(struct.numField, initialStruct.numField); Assert.assertEquals(struct.textField, initialStruct.textField); }