Skip to content

Commit

Permalink
don't include _metadata on thing serialization
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Weirich <matthias.weirich@selectcode.de>
  • Loading branch information
vavido committed Feb 8, 2021
1 parent 5c4938c commit 3b7d071
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 0 additions & 2 deletions javascript/lib/api/src/model/things.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>([
['thingId', this.thingId],
Expand All @@ -69,7 +68,6 @@ export class Thing extends EntityWithId {
['features', featuresObj],
['_revision', this._revision],
['_modified', this._modified],
['_metadata', metadataObj],
['acl', aclObj]
]));
}
Expand Down
17 changes: 15 additions & 2 deletions javascript/lib/api/tests/model/things.model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 3b7d071

Please sign in to comment.