From 3b7d071d96c6f8b83d3a5914ef4e90559ccb6101 Mon Sep 17 00:00:00 2001 From: Matthias Weirich Date: Mon, 8 Feb 2021 17:00:24 +0100 Subject: [PATCH] don't include _metadata on thing serialization Signed-off-by: Matthias Weirich --- javascript/lib/api/src/model/things.model.ts | 2 -- .../lib/api/tests/model/things.model.spec.ts | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/javascript/lib/api/src/model/things.model.ts b/javascript/lib/api/src/model/things.model.ts index 964736e2..f31eae62 100644 --- a/javascript/lib/api/src/model/things.model.ts +++ b/javascript/lib/api/src/model/things.model.ts @@ -60,7 +60,6 @@ export class Thing extends EntityWithId { public toObject(): object { const featuresObj = Features.toObject(this.features); - const metadataObj = this._metadata ? this._metadata.toObject() : undefined; const aclObj = Acl.toObject(this._acl); return EntityModel.buildObject(new Map([ ['thingId', this.thingId], @@ -69,7 +68,6 @@ export class Thing extends EntityWithId { ['features', featuresObj], ['_revision', this._revision], ['_modified', this._modified], - ['_metadata', metadataObj], ['acl', aclObj] ])); } diff --git a/javascript/lib/api/tests/model/things.model.spec.ts b/javascript/lib/api/tests/model/things.model.spec.ts index 8aba5258..7115ed7e 100644 --- a/javascript/lib/api/tests/model/things.model.spec.ts +++ b/javascript/lib/api/tests/model/things.model.spec.ts @@ -42,7 +42,20 @@ const thingObj = { _metadata: metadataObject, acl: aclObj }; + +const thingObjWithoutMetadata = { + attributes, + thingId: 'Testspace:Testthing', + policyId: 'PolicyId', + features: featuresObj, + _revision: 0, + _modified: '08042019', + acl: aclObj +}; + const responseObj = { items: [thingObj], nextPageOffset: 0 }; +const responseObjWithoutMetadata = { items: [thingObjWithoutMetadata], nextPageOffset: 0 }; + const aFeature = new Feature('additionalProp1', aDefinition, someProperties); const anotherFeature = new Feature('additionalProp2', anotherDefinition, moreProperties); const typedFeatureObject = { additionalProp1: aFeature, additionalProp2: anotherFeature }; @@ -145,7 +158,7 @@ describe('Thing', () => { expect(Thing.fromObject(thingObj).equals(thing)).toBe(true); }); it('builds an object', () => { - expect(thing.toObject()).toEqual(thingObj); + expect(thing.toObject()).toEqual(thingObjWithoutMetadata); }); it('returns its content', () => { expect(thing.thingId).toEqual('Testspace:Testthing'); @@ -181,7 +194,7 @@ describe('SearchThingsResponse', () => { expect(SearchThingsResponse.fromObject(responseObj).equals(response)).toBe(true); }); it('builds an object', () => { - expect(response.toObject()).toEqual(responseObj); + expect(response.toObject()).toEqual(responseObjWithoutMetadata); }); it('returns its content', () => { expect(response.items).toEqual([thing]);