Skip to content

Commit

Permalink
fix MapGetAllCodec
Browse files Browse the repository at this point in the history
  • Loading branch information
Mustafa Iman authored and Mustafa Iman committed Apr 27, 2016
1 parent 8b00a3e commit da42b3f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
18 changes: 10 additions & 8 deletions src/codec/MapGetAllCodec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* tslint:disable */
import ClientMessage = require('../ClientMessage');
import ImmutableLazyDataList = require('./ImmutableLazyDataList');
import {BitsUtil} from '../BitsUtil';
import Address = require('../Address');
import {AddressCodec} from './AddressCodec';
import {MemberCodec} from './MemberCodec';
import {Data} from '../serialization/Data';
import {EntryViewCodec} from './EntryViewCodec';
import DistributedObjectInfoCodec = require('./DistributedObjectInfoCodec');
import {MapMessageType} from './MapMessageType';

var REQUEST_TYPE = MapMessageType.MAP_GETALL;
Expand All @@ -16,14 +16,13 @@ var RETRYABLE = false;

export class MapGetAllCodec {


static calculateSize(name:string, keys:any) {
// Calculates the request payload size
var dataSize:number = 0;
dataSize += BitsUtil.calculateSizeString(name);
dataSize += BitsUtil.INT_SIZE_IN_BYTES;

keys.foreach((keysItem:any) => {
keys.forEach((keysItem:any) => {
dataSize += BitsUtil.calculateSizeData(keysItem);
});
return dataSize;
Expand All @@ -37,7 +36,7 @@ export class MapGetAllCodec {
clientMessage.appendString(name);
clientMessage.appendInt32(keys.length);

keys.foreach((keysItem:any) => {
keys.forEach((keysItem:any) => {
clientMessage.appendData(keysItem);
});

Expand All @@ -50,15 +49,18 @@ export class MapGetAllCodec {
var parameters:any = {'response': null};
var responseSize = clientMessage.readInt32();
var response:any = [];
for (var responseIndex = 0; responseIndex <= responseSize; responseIndex++) {
for (var responseIndex = 0; responseIndex < responseSize; responseIndex++) {
var responseItem:any;
responseItem = clientMessage.readMapEntry();
var responseItemKey:Data;
var responseItemVal:any;
responseItemKey = clientMessage.readData();
responseItemVal = clientMessage.readData();
responseItem = [responseItemKey, responseItemVal];
response.push(responseItem)
}
parameters['response'] = new ImmutableLazyDataList(response, toObjectFunction);
parameters['response'] = response;
return parameters;

}


}
25 changes: 24 additions & 1 deletion test/MapProxyTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ describe("MapProxy Test", function() {
})
});

it.skip('getAll', function() {
return map.getAll([
'key0', 'key1', 'key2', 'key3', 'key4',
'key5', 'key6', 'key7', 'key8', 'key9'
]).then(function (values) {
return expect(values).to.deep.have.members([
['key0', 'val0'], ['key1', 'val1'],
['key2', 'val2'], ['key3', 'val3'],
['key4', 'val4'], ['key5', 'val5'],
['key6', 'val6'], ['key7', 'val7'],
['key8', 'val8'], ['key9', 'val9']
]);
})
});

it('delete', function() {
return map.put('key-to-delete', 'value').then(function() {
return map.delete('key-to-delete');
Expand Down Expand Up @@ -264,7 +279,15 @@ describe("MapProxy Test", function() {
});
});

it('forceUnlock');
it('forceUnlock', function() {
return map.lock('key0').then(function() {
return map.forceUnlock('key0');
}).then(function() {
return map.isLocked('key0');
}).then(function(isLocked) {
return expect(isLocked).to.be.false;
});
});

it('keySet', function() {
return map.keySet().then(function(keySet) {
Expand Down

0 comments on commit da42b3f

Please sign in to comment.