Skip to content
Snippets Groups Projects
Commit ce8bbc75 authored by Nils Brinckmann's avatar Nils Brinckmann
Browse files

Project model

parent a1ba66b1
No related branches found
No related tags found
2 merge requests!57WIP: Feature oidc gfz integrated work,!53Feature basic configuration api
/**
* @license
* Web client of the Sensor Management System software developed within
* the Helmholtz DataHub Initiative by GFZ and UFZ.
*
* Copyright (C) 2020
* - Nils Brinckmann (GFZ, nils.brinckmann@gfz-potsdam.de)
* - Marc Hanisch (GFZ, marc.hanisch@gfz-potsdam.de)
* - Helmholtz Centre Potsdam - GFZ German Research Centre for
* Geosciences (GFZ, https://www.gfz-potsdam.de)
*
* Parts of this program were developed within the context of the
* following publicly funded projects or measures:
* - Helmholtz Earth and Environment DataHub
* (https://www.helmholtz.de/en/research/earth_and_environment/initiatives/#h51095)
*
* Licensed under the HEESIL, Version 1.0 or - as soon they will be
* approved by the "Community" - subsequent versions of the HEESIL
* (the "Licence").
*
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://gitext.gfz-potsdam.de/software/heesil
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the Licence for the specific language governing
* permissions and limitations under the Licence.
*/
export interface IProject {
id: string
name: string
uri: string
}
export class Project implements IProject {
private _id: string = ''
private _name: string = ''
private _uri: string = ''
get id (): string {
return this._id
}
set id (newId: string) {
this._id = newId
}
get name (): string {
return this._name
}
set name (newName: string) {
this._name = newName
}
get uri (): string {
return this._uri
}
set uri (newUri: string) {
this._uri = newUri
}
toString (): string {
return this._name
}
static createWithData (id: string, name: string, uri: string): Project {
const result = new Project()
result.id = id
result.name = name
result.uri = uri
return result
}
static createFromObject (someObject: IProject): Project {
const newObject = new Project()
newObject.id = someObject.id
newObject.name = someObject.name
newObject.uri = someObject.uri
return newObject
}
}
/**
* @license
* Web client of the Sensor Management System software developed within
* the Helmholtz DataHub Initiative by GFZ and UFZ.
*
* Copyright (C) 2020
* - Nils Brinckmann (GFZ, nils.brinckmann@gfz-potsdam.de)
* - Marc Hanisch (GFZ, marc.hanisch@gfz-potsdam.de)
* - Helmholtz Centre Potsdam - GFZ German Research Centre for
* Geosciences (GFZ, https://www.gfz-potsdam.de)
*
* Parts of this program were developed within the context of the
* following publicly funded projects or measures:
* - Helmholtz Earth and Environment DataHub
* (https://www.helmholtz.de/en/research/earth_and_environment/initiatives/#h51095)
*
* Licensed under the HEESIL, Version 1.0 or - as soon they will be
* approved by the "Community" - subsequent versions of the HEESIL
* (the "Licence").
*
* You may not use this work except in compliance with the Licence.
*
* You may obtain a copy of the Licence at:
* https://gitext.gfz-potsdam.de/software/heesil
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the Licence for the specific language governing
* permissions and limitations under the Licence.
*/
import { Project } from '@/models/Project'
describe('Project', () => {
describe('#id', () => {
it('should be an empty string for a new object', () => {
const emptyProject = new Project()
expect(emptyProject.id).toEqual('')
})
it('should be possible to set it', () => {
const project = new Project()
project.id = 'newid'
expect(project.id).toEqual('newid')
})
})
describe('#name', () => {
it('should be an empty string for a new object', () => {
const emptyProject = new Project()
expect(emptyProject.name).toEqual('')
})
it('should be possible to set it', () => {
const project = new Project()
project.name = 'new name'
expect(project.name).toEqual('new name')
})
})
describe('#uri', () => {
it('should be an empty string for a new object', () => {
const emptyProject = new Project()
expect(emptyProject.uri).toEqual('')
})
it('should be possible t oset it', () => {
const project = new Project()
project.uri = 'newuri'
expect(project.uri).toEqual('newuri')
})
})
describe('#toString', () => {
it('should be equal to the name', () => {
const namesToSet = ['abc', 'cde']
for (const name of namesToSet) {
const project = new Project()
project.name = name
expect(project.toString()).toEqual(name)
}
})
})
describe('#createWithData', () => {
it('should be possible to create the object right away with some data', () => {
const project = Project.createWithData(
'someId',
'some name',
'someuri'
)
expect(project.id).toEqual('someId')
expect(project.name).toEqual('some name')
expect(project.uri).toEqual('someuri')
})
})
describe('#createFromObject', () => {
it('should be possible to create from an object', () => {
const project = Project.createFromObject({
id: 'someId',
name: 'some name',
uri: 'someuri'
})
expect(project.id).toEqual('someId')
expect(project.name).toEqual('some name')
expect(project.uri).toEqual('someuri')
})
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment