src/app/services/file-sharing/file-sharing.service.spec.ts
import { TestBed, inject } from '@angular/core/testing';
import { FileSharingService } from './file-sharing.service';
// tslint:disable-next-line:max-line-length
import { Statistics, Configuration, ProcessInstance, ActivityInstance, ResourceInstance, Resource, Activity, Process, ResourceUtilization } from './process-statistics';
import { Parser } from 'xml2js';
import { parseNumbers } from 'xml2js/lib/processors';
import {cleanXML} from './xml-postprocessor';
describe('FileSharingService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [FileSharingService]
});
});
it('should be created', inject([FileSharingService], (service: FileSharingService) => {
expect(service).toBeTruthy();
}));
});
describe('xml2js parser', () => {
let parser: Parser;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [FileSharingService]
});
parser = new Parser({valueProcessors: [parseNumbers], explicitRoot: false, explicitArray: false});
});
it('should parse Statistics interface', () => {
const xml = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<min>375.0</min>
<max>960.0</max>
<median>375.0</median>
<Q1>375.0</Q1>
<Q3>960.0</Q3>
<avg>570.0</avg>
<total>1710.0</total>
</root>
`;
let parsed: Statistics; // any;
parser.parseString(xml, function (err, result) {
parsed = result;
});
expect(parsed.min).toBe(375.0);
expect(parsed.max).toBe(960.0);
expect(parsed.median).toBe(375.0);
expect(parsed.Q1).toBe(375.0);
expect(parsed.Q3).toBe(960.0);
expect(parsed.avg).toBe(570.0);
expect(parsed.total).toBe(1710.0);
});
it('should parse Configuration interface', () => {
const xml = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration>
<time_unit>SECONDS</time_unit>
</configuration>
`;
let parsed: Configuration;
parser.parseString(xml, function(err, result) {
parsed = result;
});
expect(parsed.time_unit).toEqual('SECONDS');
});
it('should parse ProcessInstance interface', () => {
const xml = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<instance>
<costs>960.0</costs>
<time>
<duration>6600</duration>
<effective>3000</effective>
<waiting>3600</waiting>
<offTime>0</offTime>
</time>
</instance>
`;
let parsed: ProcessInstance;
parser.parseString(xml, function(err, result) {
parsed = result;
});
expect(parsed.costs).toBe(960);
expect(parsed.time.duration).toBe(6600);
expect(parsed.time.effective).toBe(3000);
expect(parsed.time.waiting).toBe(3600);
expect(parsed.time.offTime).toBe(0);
});
it('should parse ActivityInstance interface', () => {
const xml = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
`;
let parsed: ActivityInstance;
parser.parseString(xml, function(err, result) {
parsed = result;
});
expect(parsed.cost).toBe(0);
expect(parsed.time.effective).toBe(0);
expect(parsed.time.waiting).toBe(0);
expect(parsed.time.resources_idle).toBe(0);
});
it('should parse ResourceInstance interface', () => {
const xml = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<instance>
<id>#2</id>
<cost>35721.33333333333</cost>
<time>
<in_use>109986</in_use>
<available>214328</available>
<workload>0.5131667350976074</workload>
</time>
</instance>
`;
let parsed: ResourceInstance;
parser.parseString(xml, function(err, result) {
parsed = result;
});
expect(parsed.cost).toBe(35721.33333333333);
expect(parsed.id).toEqual('#2');
expect(parsed.time.in_use).toBe(109986);
expect(parsed.time.available).toBe(214328);
expect(parsed.time.workload).toBe(0.5131667350976074);
});
it('should parse Resource interface', () => {
//#region XML
const xml = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resource>
<type>Student</type>
<cost>
<min>35721.33333333333</min>
<max>35721.33333333333</max>
<median>35721.33333333333</median>
<Q1>35721.33333333333</Q1>
<Q3>35721.33333333333</Q3>
<avg>35721.33333333333</avg>
<total>178606.66666666663</total>
</cost>
<time>
<in_use>
<min>94537.0</min>
<max>114714.0</max>
<median>104618.0</median>
<Q1>99263.0</Q1>
<Q3>109986.0</Q3>
<avg>104623.6</avg>
<total>523118.0</total>
</in_use>
<available>
<min>214328.0</min>
<max>214328.0</max>
<median>214328.0</median>
<Q1>214328.0</Q1>
<Q3>214328.0</Q3>
<avg>214328.0</avg>
<total>1071640.0</total>
</available>
<workload>
<min>0.4410856257698481</min>
<max>0.5352263819939532</max>
<median>0.48812101078720466</median>
<Q1>0.4631359411742749</Q1>
<Q3>0.5131667350976074</Q3>
<avg>0.4881471389645776</avg>
<total>2.440735694822888</total>
</workload>
</time>
<instances>
<instance>
<id>#3</id>
<cost>35721.33333333333</cost>
<time>
<in_use>94537</in_use>
<available>214328</available>
<workload>0.4410856257698481</workload>
</time>
</instance>
<instance>
<id>#4</id>
<cost>35721.33333333333</cost>
<time>
<in_use>104618</in_use>
<available>214328</available>
<workload>0.48812101078720466</workload>
</time>
</instance>
<instance>
<id>#0</id>
<cost>35721.33333333333</cost>
<time>
<in_use>114714</in_use>
<available>214328</available>
<workload>0.5352263819939532</workload>
</time>
</instance>
<instance>
<id>#1</id>
<cost>35721.33333333333</cost>
<time>
<in_use>99263</in_use>
<available>214328</available>
<workload>0.4631359411742749</workload>
</time>
</instance>
<instance>
<id>#2</id>
<cost>35721.33333333333</cost>
<time>
<in_use>109986</in_use>
<available>214328</available>
<workload>0.5131667350976074</workload>
</time>
</instance>
</instances>
</resource>
`;
//#endregion
let parsed: Resource;
// parser = new Parser({explicitRoot: false, explicitArray: false});
parser.parseString(xml, function(err, result) {
parsed = cleanXML(result);
});
expect(parsed.cost.max).toBe(35721.33333333333);
expect(parsed.cost.Q1).toBe(35721.33333333333);
expect(parsed.instances.length).toBe(5);
expect(parsed.instances.find(instance => instance.id === '#1').cost).toBe(35721.33333333333);
expect(parsed.instances.find(instance => instance.id === '#0').time.available).toBe(214328);
expect(parsed.instances.map(instance => instance.id).sort()).toEqual(['#0', '#1', '#2', '#3', '#4']);
});
it('should parse the Activity interface', () => {
//#region XML
const xml = `
<activity>
<id>3</id>
<name>write thesis</name>
<cost>
<min>0.0</min>
<max>1491.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1491.0</Q3>
<avg>497.0</avg>
<total>1491.0</total>
</cost>
<time>
<duration>
<min>0.0</min>
<max>1491.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1491.0</Q3>
<avg>497.0</avg>
<total>1491.0</total>
</duration>
<waiting>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</waiting>
<resources_idle>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</resources_idle>
</time>
<instances>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>1491.0</cost>
<time>
<effective>1491</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
</instances>
</activity>
`;
//#endregion
let parsed: Activity;
parser.parseString(xml, function(err, result) {
parsed = cleanXML(result);
});
expect(parsed.cost.total).toBe(1491);
// expect(parsed.id).toEqual('3');
expect(parsed.name).toEqual('write thesis');
expect(parsed.time.duration.max).toBe(1491);
expect(parsed.instances.length).toBe(3);
// expect(parsed.instances.find(instance => instance.id === '1').cost).toBe(0);
// expect(parsed.instances.find(instance => instance.id === '2').time.effective).toBe(1491);
});
it('should parse Process interface', () => {
//#region XML
const xml = `
<processes>
<process>
<id>Process_8</id>
<cost>
<min>4616.166666666666</min>
<max>6314.333333333333</max>
<median>5723.333333333333</median>
<Q1>5289.0</Q1>
<Q3>6000.5</Q3>
<avg>5594.766666666667</avg>
<total>167843.00000000003</total>
</cost>
<time>
<flow_time>
<min>16122.0</min>
<max>26412.0</max>
<median>19612.0</median>
<Q1>18084.0</Q1>
<Q3>22694.0</Q3>
<avg>20425.333333333332</avg>
<total>612760.0</total>
</flow_time>
<effective>
<min>16122.0</min>
<max>21598.0</max>
<median>19127.0</median>
<Q1>18049.0</Q1>
<Q3>19718.0</Q3>
<avg>18985.266666666666</avg>
<total>569558.0</total>
</effective>
<waiting>
<min>0.0</min>
<max>6813.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>4105.0</Q3>
<avg>1440.0666666666666</avg>
<total>43202.0</total>
</waiting>
<off_timetable>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</off_timetable>
</time>
<instances>
<instance>
<costs>4616.166666666666</costs>
<time>
<duration>17717</duration>
<effective>17717</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5593.166666666666</costs>
<time>
<duration>18154</duration>
<effective>18154</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5456.333333333333</costs>
<time>
<duration>19758</duration>
<effective>19758</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6000.5</costs>
<time>
<duration>20423</duration>
<effective>20423</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5456.333333333333</costs>
<time>
<duration>17323</duration>
<effective>17323</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4992.833333333333</costs>
<time>
<duration>17862</duration>
<effective>17862</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5022.333333333334</costs>
<time>
<duration>18049</duration>
<effective>18049</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6310.5</costs>
<time>
<duration>19493</duration>
<effective>19493</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5738.0</costs>
<time>
<duration>19718</duration>
<effective>19718</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5824.666666666666</costs>
<time>
<duration>21598</duration>
<effective>21598</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6226.166666666666</costs>
<time>
<duration>19612</duration>
<effective>19612</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4624.0</costs>
<time>
<duration>18084</duration>
<effective>18084</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4967.833333333333</costs>
<time>
<duration>16122</duration>
<effective>16122</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5723.333333333333</costs>
<time>
<duration>20070</duration>
<effective>20070</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6031.0</costs>
<time>
<duration>17801</duration>
<effective>17801</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5499.0</costs>
<time>
<duration>19319</duration>
<effective>19319</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5289.0</costs>
<time>
<duration>18039</duration>
<effective>18039</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5047.0</costs>
<time>
<duration>18777</duration>
<effective>18777</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6057.0</costs>
<time>
<duration>20417</duration>
<effective>20417</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5931.666666666666</costs>
<time>
<duration>19600</duration>
<effective>19600</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4619.833333333333</costs>
<time>
<duration>18374</duration>
<effective>18374</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6042.833333333333</costs>
<time>
<duration>23589</duration>
<effective>19127</effective>
<waiting>4462</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5847.5</costs>
<time>
<duration>24061</duration>
<effective>17750</effective>
<waiting>6311</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6314.333333333333</costs>
<time>
<duration>24954</duration>
<effective>20066</effective>
<waiting>4888</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5846.166666666666</costs>
<time>
<duration>25656</duration>
<effective>19522</effective>
<waiting>6134</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6067.0</costs>
<time>
<duration>24359</duration>
<effective>19217</effective>
<waiting>5142</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5921.5</costs>
<time>
<duration>26412</duration>
<effective>19599</effective>
<waiting>6813</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5773.166666666666</costs>
<time>
<duration>22694</duration>
<effective>18589</effective>
<waiting>4105</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5690.333333333333</costs>
<time>
<duration>24961</duration>
<effective>20472</effective>
<waiting>4489</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5313.5</costs>
<time>
<duration>19764</duration>
<effective>18906</effective>
<waiting>858</waiting>
<offTime>0</offTime>
</time>
</instance>
</instances>
<activities>
<activity>
<id>2</id>
<name>write paper</name>
<cost>
<min>0.0</min>
<max>2672.5</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>2672.5</Q3>
<avg>890.8333333333334</avg>
<total>2672.5</total>
</cost>
<time>
<duration>
<min>0.0</min>
<max>16035.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>16035.0</Q3>
<avg>5345.0</avg>
<total>16035.0</total>
</duration>
<waiting>
<min>0.0</min>
<max>858.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>858.0</Q3>
<avg>286.0</avg>
<total>858.0</total>
</waiting>
<resources_idle>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</resources_idle>
</time>
<instances>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>858</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>2672.5</cost>
<time>
<effective>16035</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
</instances>
</activity>
<activity>
<id>3</id>
<name>write thesis</name>
<cost>
<min>0.0</min>
<max>1491.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1491.0</Q3>
<avg>497.0</avg>
<total>1491.0</total>
</cost>
<time>
<duration>
<min>0.0</min>
<max>1491.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1491.0</Q3>
<avg>497.0</avg>
<total>1491.0</total>
</duration>
<waiting>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</waiting>
<resources_idle>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</resources_idle>
</time>
<instances>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>1491.0</cost>
<time>
<effective>1491</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
</instances>
</activity>
<activity>
<id>4</id>
<name>be happy</name>
<cost>
<min>0.0</min>
<max>1150.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1150.0</Q3>
<avg>383.3333333333333</avg>
<total>1150.0</total>
</cost>
<time>
<duration>
<min>0.0</min>
<max>1380.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1380.0</Q3>
<avg>460.0</avg>
<total>1380.0</total>
</duration>
<waiting>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</waiting>
<resources_idle>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</resources_idle>
</time>
<instances>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>1150.0</cost>
<time>
<effective>1380</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
</instances>
</activity>
</activities>
</process>
</processes>
`;
//#endregion
let parsed: any;
parser.parseString(xml, function(err, result) {
parsed = cleanXML(result);
});
const process = parsed.process;
expect(process.id).toEqual('Process_8');
expect(process.cost.total).toBe(167843.00000000003);
expect(process.instances.length).toBe(30);
});
it('should parse the whole resource utilization', () => {
//#region xml
const xml = `
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resourceUtilization>
<configuration>
<time_unit>SECONDS</time_unit>
</configuration>
<processes>
<process>
<id>Process_8</id>
<cost>
<min>4616.166666666666</min>
<max>6314.333333333333</max>
<median>5723.333333333333</median>
<Q1>5289.0</Q1>
<Q3>6000.5</Q3>
<avg>5594.766666666667</avg>
<total>167843.00000000003</total>
</cost>
<time>
<flow_time>
<min>16122.0</min>
<max>26412.0</max>
<median>19612.0</median>
<Q1>18084.0</Q1>
<Q3>22694.0</Q3>
<avg>20425.333333333332</avg>
<total>612760.0</total>
</flow_time>
<effective>
<min>16122.0</min>
<max>21598.0</max>
<median>19127.0</median>
<Q1>18049.0</Q1>
<Q3>19718.0</Q3>
<avg>18985.266666666666</avg>
<total>569558.0</total>
</effective>
<waiting>
<min>0.0</min>
<max>6813.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>4105.0</Q3>
<avg>1440.0666666666666</avg>
<total>43202.0</total>
</waiting>
<off_timetable>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</off_timetable>
</time>
<instances>
<instance>
<costs>4616.166666666666</costs>
<time>
<duration>17717</duration>
<effective>17717</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5593.166666666666</costs>
<time>
<duration>18154</duration>
<effective>18154</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5456.333333333333</costs>
<time>
<duration>19758</duration>
<effective>19758</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6000.5</costs>
<time>
<duration>20423</duration>
<effective>20423</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5456.333333333333</costs>
<time>
<duration>17323</duration>
<effective>17323</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4992.833333333333</costs>
<time>
<duration>17862</duration>
<effective>17862</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5022.333333333334</costs>
<time>
<duration>18049</duration>
<effective>18049</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6310.5</costs>
<time>
<duration>19493</duration>
<effective>19493</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5738.0</costs>
<time>
<duration>19718</duration>
<effective>19718</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5824.666666666666</costs>
<time>
<duration>21598</duration>
<effective>21598</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6226.166666666666</costs>
<time>
<duration>19612</duration>
<effective>19612</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4624.0</costs>
<time>
<duration>18084</duration>
<effective>18084</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4967.833333333333</costs>
<time>
<duration>16122</duration>
<effective>16122</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5723.333333333333</costs>
<time>
<duration>20070</duration>
<effective>20070</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6031.0</costs>
<time>
<duration>17801</duration>
<effective>17801</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5499.0</costs>
<time>
<duration>19319</duration>
<effective>19319</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5289.0</costs>
<time>
<duration>18039</duration>
<effective>18039</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5047.0</costs>
<time>
<duration>18777</duration>
<effective>18777</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6057.0</costs>
<time>
<duration>20417</duration>
<effective>20417</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5931.666666666666</costs>
<time>
<duration>19600</duration>
<effective>19600</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>4619.833333333333</costs>
<time>
<duration>18374</duration>
<effective>18374</effective>
<waiting>0</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6042.833333333333</costs>
<time>
<duration>23589</duration>
<effective>19127</effective>
<waiting>4462</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5847.5</costs>
<time>
<duration>24061</duration>
<effective>17750</effective>
<waiting>6311</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6314.333333333333</costs>
<time>
<duration>24954</duration>
<effective>20066</effective>
<waiting>4888</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5846.166666666666</costs>
<time>
<duration>25656</duration>
<effective>19522</effective>
<waiting>6134</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>6067.0</costs>
<time>
<duration>24359</duration>
<effective>19217</effective>
<waiting>5142</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5921.5</costs>
<time>
<duration>26412</duration>
<effective>19599</effective>
<waiting>6813</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5773.166666666666</costs>
<time>
<duration>22694</duration>
<effective>18589</effective>
<waiting>4105</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5690.333333333333</costs>
<time>
<duration>24961</duration>
<effective>20472</effective>
<waiting>4489</waiting>
<offTime>0</offTime>
</time>
</instance>
<instance>
<costs>5313.5</costs>
<time>
<duration>19764</duration>
<effective>18906</effective>
<waiting>858</waiting>
<offTime>0</offTime>
</time>
</instance>
</instances>
<activities>
<activity>
<id>2</id>
<name>write paper</name>
<cost>
<min>0.0</min>
<max>2672.5</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>2672.5</Q3>
<avg>890.8333333333334</avg>
<total>2672.5</total>
</cost>
<time>
<duration>
<min>0.0</min>
<max>16035.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>16035.0</Q3>
<avg>5345.0</avg>
<total>16035.0</total>
</duration>
<waiting>
<min>0.0</min>
<max>858.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>858.0</Q3>
<avg>286.0</avg>
<total>858.0</total>
</waiting>
<resources_idle>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</resources_idle>
</time>
<instances>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>858</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>2672.5</cost>
<time>
<effective>16035</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
</instances>
</activity>
<activity>
<id>3</id>
<name>write thesis</name>
<cost>
<min>0.0</min>
<max>1491.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1491.0</Q3>
<avg>497.0</avg>
<total>1491.0</total>
</cost>
<time>
<duration>
<min>0.0</min>
<max>1491.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1491.0</Q3>
<avg>497.0</avg>
<total>1491.0</total>
</duration>
<waiting>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</waiting>
<resources_idle>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</resources_idle>
</time>
<instances>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>1491.0</cost>
<time>
<effective>1491</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
</instances>
</activity>
<activity>
<id>4</id>
<name>be happy</name>
<cost>
<min>0.0</min>
<max>1150.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1150.0</Q3>
<avg>383.3333333333333</avg>
<total>1150.0</total>
</cost>
<time>
<duration>
<min>0.0</min>
<max>1380.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>1380.0</Q3>
<avg>460.0</avg>
<total>1380.0</total>
</duration>
<waiting>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</waiting>
<resources_idle>
<min>0.0</min>
<max>0.0</max>
<median>0.0</median>
<Q1>0.0</Q1>
<Q3>0.0</Q3>
<avg>0.0</avg>
<total>0.0</total>
</resources_idle>
</time>
<instances>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>0.0</cost>
<time>
<effective>0</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
<instance>
<cost>1150.0</cost>
<time>
<effective>1380</effective>
<waiting>0</waiting>
<resources_idle>0</resources_idle>
</time>
</instance>
</instances>
</activity>
</activities>
</process>
</processes>
<resources>
<resource>
<type>Professor</type>
<cost>
<min>178606.6666666667</min>
<max>178606.6666666667</max>
<median>178606.6666666667</median>
<Q1>178606.6666666667</Q1>
<Q3>178606.6666666667</Q3>
<avg>178606.6666666667</avg>
<total>357213.3333333334</total>
</cost>
<time>
<in_use>
<min>45237.0</min>
<max>51551.0</max>
<median>45237.0</median>
<Q1>45237.0</Q1>
<Q3>51551.0</Q3>
<avg>48394.0</avg>
<total>96788.0</total>
</in_use>
<available>
<min>214328.0</min>
<max>214328.0</max>
<median>214328.0</median>
<Q1>214328.0</Q1>
<Q3>214328.0</Q3>
<avg>214328.0</avg>
<total>428656.0</total>
</available>
<workload>
<min>0.21106434996827292</min>
<max>0.24052386995632863</max>
<median>0.21106434996827292</median>
<Q1>0.21106434996827292</Q1>
<Q3>0.24052386995632863</Q3>
<avg>0.22579410996230076</avg>
<total>0.4515882199246015</total>
</workload>
</time>
<instances>
<instance>
<id>#0</id>
<cost>178606.6666666667</cost>
<time>
<in_use>51551</in_use>
<available>214328</available>
<workload>0.24052386995632863</workload>
</time>
</instance>
<instance>
<id>#1</id>
<cost>178606.6666666667</cost>
<time>
<in_use>45237</in_use>
<available>214328</available>
<workload>0.21106434996827292</workload>
</time>
</instance>
</instances>
</resource>
<resource>
<type>Student</type>
<cost>
<min>35721.33333333333</min>
<max>35721.33333333333</max>
<median>35721.33333333333</median>
<Q1>35721.33333333333</Q1>
<Q3>35721.33333333333</Q3>
<avg>35721.33333333333</avg>
<total>178606.66666666663</total>
</cost>
<time>
<in_use>
<min>94537.0</min>
<max>114714.0</max>
<median>104618.0</median>
<Q1>99263.0</Q1>
<Q3>109986.0</Q3>
<avg>104623.6</avg>
<total>523118.0</total>
</in_use>
<available>
<min>214328.0</min>
<max>214328.0</max>
<median>214328.0</median>
<Q1>214328.0</Q1>
<Q3>214328.0</Q3>
<avg>214328.0</avg>
<total>1071640.0</total>
</available>
<workload>
<min>0.4410856257698481</min>
<max>0.5352263819939532</max>
<median>0.48812101078720466</median>
<Q1>0.4631359411742749</Q1>
<Q3>0.5131667350976074</Q3>
<avg>0.4881471389645776</avg>
<total>2.440735694822888</total>
</workload>
</time>
<instances>
<instance>
<id>#3</id>
<cost>35721.33333333333</cost>
<time>
<in_use>94537</in_use>
<available>214328</available>
<workload>0.4410856257698481</workload>
</time>
</instance>
<instance>
<id>#4</id>
<cost>35721.33333333333</cost>
<time>
<in_use>104618</in_use>
<available>214328</available>
<workload>0.48812101078720466</workload>
</time>
</instance>
<instance>
<id>#0</id>
<cost>35721.33333333333</cost>
<time>
<in_use>114714</in_use>
<available>214328</available>
<workload>0.5352263819939532</workload>
</time>
</instance>
<instance>
<id>#1</id>
<cost>35721.33333333333</cost>
<time>
<in_use>99263</in_use>
<available>214328</available>
<workload>0.4631359411742749</workload>
</time>
</instance>
<instance>
<id>#2</id>
<cost>35721.33333333333</cost>
<time>
<in_use>109986</in_use>
<available>214328</available>
<workload>0.5131667350976074</workload>
</time>
</instance>
</instances>
</resource>
</resources>
</resourceUtilization>
`;
//#endregion
let parsed: ResourceUtilization;
parser.parseString(xml, function(err, result) {
parsed = cleanXML(result);
});
// const process = parsed.processes.find(proc => proc.id === 'Process_8');
const process = parsed.processes.process;
const resources = parsed.resources;
const config = parsed.configuration;
expect(config.time_unit).toEqual('SECONDS');
expect(process.id).toEqual('Process_8');
expect(process.activities.length).toBe(3);
expect(process.instances.length).toBe(30);
expect(resources.length).toBe(2);
});
});