diff --git a/ngapp/src/app/connections/shared/connection-status.spec.ts b/ngapp/src/app/connections/shared/connection-status.spec.ts new file mode 100644 index 00000000..07b58a53 --- /dev/null +++ b/ngapp/src/app/connections/shared/connection-status.spec.ts @@ -0,0 +1,35 @@ +import { ConnectionStatus } from "@connections/shared/connection-status"; + +describe("ConnectionStatus", () => { + let connectionStatus: ConnectionStatus; + + beforeEach(() => { + connectionStatus = null; + }); + + it("should create", () => { + console.log("========== [ConnectionStatus] should create"); + connectionStatus = ConnectionStatus.create( + { + "connectionName": "PgConn", + "vdbState": "ACTIVE", + "schemaState": "ACTIVE", + "errors": [], + "schemaModelName": "pgconnschemamodel", + "schemaVdbName": "pgconnschemavdb", + "vdbName": "pgconnbtlconn" + } + ); + + expect(connectionStatus.getConnectionName()).toEqual("PgConn"); + expect(connectionStatus.getSchemaModelName()).toEqual("pgconnschemamodel"); + expect(connectionStatus.getSchemaVdbName()).toEqual("pgconnschemavdb"); + expect(connectionStatus.getServerVdbName()).toEqual("pgconnbtlconn"); + expect(connectionStatus.getErrors()).toEqual([]); + expect(connectionStatus.isServerVdbActive()).toEqual(true); + expect(connectionStatus.isServerVdbMissing()).toEqual(false); + expect(connectionStatus.isServerVdbLoading()).toEqual(false); + expect(connectionStatus.isServerVdbFailed()).toEqual(false); + }); + +}); diff --git a/ngapp/src/app/connections/shared/connection.model.spec.ts b/ngapp/src/app/connections/shared/connection.model.spec.ts new file mode 100644 index 00000000..68db8c61 --- /dev/null +++ b/ngapp/src/app/connections/shared/connection.model.spec.ts @@ -0,0 +1,57 @@ +import { Connection } from "@connections/shared/connection.model"; + +describe("Connection", () => { + let connection: Connection; + + beforeEach(() => { + connection = null; + }); + + it("should create", () => { + console.log("========== [Connection] should create"); + connection = Connection.create( + { + "keng__baseUri": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/", + "keng__id": "PgConn", + "keng__dataPath": "/tko:komodo/tko:workspace/admin/PgConn", + "keng__kType": "Connection", + "keng__hasChildren": true, + "dv__jndiName": "java:/postgresql-persistent-jq7wz", + "dv__driverName": "postgresql", + "dv__type": true, + "keng__properties": [ + { + "name": "description", + "value": "customer db on postgres" + }, + { + "name": "serviceCatalogSource", + "value": "postgresql-persistent-jq7wz" + } + ], + "keng___links": [ + { + "rel": "self", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/connections/PgConn" + }, + { + "rel": "parent", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/connections" + }, + { + "rel": "children", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/search%2Fadmin%2FPgConn" + } + ] + } + ); + + expect(connection.getId()).toEqual("PgConn"); + expect(connection.getDescription()).toEqual("customer db on postgres"); + expect(connection.getDriverName()).toEqual("postgresql"); + expect(connection.getJndiName()).toEqual("java:/postgresql-persistent-jq7wz"); + expect(connection.getServiceCatalogSourceName()).toEqual("postgresql-persistent-jq7wz"); + expect(connection.getDataPath()).toEqual("/tko:komodo/tko:workspace/admin/PgConn"); + }); + +}); diff --git a/ngapp/src/app/connections/shared/service-catalog-source.model.spec.ts b/ngapp/src/app/connections/shared/service-catalog-source.model.spec.ts new file mode 100644 index 00000000..85f1ae39 --- /dev/null +++ b/ngapp/src/app/connections/shared/service-catalog-source.model.spec.ts @@ -0,0 +1,45 @@ +import { ServiceCatalogSource } from "@connections/shared/service-catalog-source.model"; + +describe("ServiceCatalogSource", () => { + let serviceCatSrc: ServiceCatalogSource; + + beforeEach(() => { + serviceCatSrc = null; + }); + + it("should create", () => { + console.log("========== [ServiceCatalogSource] should create"); + serviceCatSrc = ServiceCatalogSource.create( + { + "keng__baseUri": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/", + "keng__id": "mongodb-persistent-762zc", + "keng__dataPath": "/tko:komodo/tko:workspace/admin/2018-05-17_20-35-29-543", + "keng__kType": "ServiceCatalogDataSource", + "keng__hasChildren": false, + "sc__name": "mongodb-persistent-762zc", + "sc__type": "mongodb", + "sc__bound": true, + "sc__translator": "mongodb", + "keng___links": [ + { + "rel": "self", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/metadata/connections/mongodb-persistent-762zc" + }, + { + "rel": "parent", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/metadata/connections" + }, + { + "rel": "children", + "href": "http://das-beetle-studio.192.168.42.1154.nip.ip/xxx" + } + ] + } + ); + + expect(serviceCatSrc.getName()).toEqual("mongodb-persistent-762zc"); + expect(serviceCatSrc.getType()).toEqual("mongodb"); + expect(serviceCatSrc.isBound()).toEqual(true); + }); + +}); diff --git a/ngapp/src/app/connections/shared/template-definition.model.ts b/ngapp/src/app/connections/shared/template-definition.model.ts deleted file mode 100644 index f707fbd2..00000000 --- a/ngapp/src/app/connections/shared/template-definition.model.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @license - * Copyright 2017 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export class TemplateDefinition { - private keng__id: string; - private isJdbc: boolean; - private entries: string[]; - - /** - * @param {Object} json the JSON representation of a Template - * @returns {TemplateDefinition} the new TemplateDefinition (never null) - */ - public static create( json: object = {} ): TemplateDefinition { - const template = new TemplateDefinition(); - template.setValues( json ); - return template; - } - - constructor() { - // nothing to do - } - - /** - * @returns {string} the property id - */ - public getId(): string { - return this.keng__id; - } - - /** - * @returns {boolean} 'true' if jdbc - */ - public getJdbc(): boolean { - return this.isJdbc; - } - - /** - * @returns {string[]} the array of entries - */ - public getEntries(): string[] { - return this.entries; - } - - /** - * @param {string} id the property id - */ - public setId( id?: string ): void { - this.keng__id = id ? id : null; - } - - /** - * @param {boolean} jdbc 'true' if template is jdbc - */ - public setJdbc( jdbc?: boolean ): void { - this.isJdbc = jdbc ? jdbc : null; - } - - /** - * @param {string[]} entries the array of entries - */ - public setEntries( entries?: string[] ): void { - this.entries = entries ? entries : null; - } - - /** - * Set all object values using the supplied Template json - * @param {Object} values - */ - public setValues(values: object = {}): void { - Object.assign(this, values); - } - -} diff --git a/ngapp/src/app/dataservices/shared/catalog-schema.model.ts b/ngapp/src/app/dataservices/shared/catalog-schema.model.ts deleted file mode 100644 index 540161cb..00000000 --- a/ngapp/src/app/dataservices/shared/catalog-schema.model.ts +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @license - * Copyright 2017 JBoss Inc - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * CatalogSchema model. The type will be 'Catalog' or 'Schema'. For Schema, the catalogName may - * or may not be set depending on whether Catalogs are supported. - */ -export class CatalogSchema { - private name: string; - private type: string; - private catalogName: string; - - constructor() { - // nothing to do - } - - /** - * @returns {string} the info name - */ - public getName(): string { - return this.name; - } - - /** - * @returns {string} the info type - */ - public getType(): string { - return this.type; - } - - /** - * @returns {string} the catalog name - */ - public getCatalogName(): string { - return this.catalogName; - } - - /** - * @returns {string} the display name - */ - public getDisplayName(): string { - const type = this.getType(); - if ( type === "Catalog" ) { - return this.getName(); - } else if ( type === "Schema" ) { - const catalog = this.getCatalogName(); - if ( catalog && catalog.length > 0 ) { - return catalog + "." + this.getName(); - } else { - return this.getName(); - } - } - return this.catalogName; - } - - /** - * @param {string} name the name - */ - public setName( name?: string ): void { - this.name = name ? name : null; - } - - /** - * @param {string} type the type - */ - public setType( type?: string ): void { - this.type = type ? type : null; - } - - /** - * @param {string} name the name of the catalog - */ - public setCatalogName( name?: string ): void { - this.catalogName = name ? name : null; - } - -} diff --git a/ngapp/src/app/dataservices/shared/connection-summary.model.spec.ts b/ngapp/src/app/dataservices/shared/connection-summary.model.spec.ts new file mode 100644 index 00000000..1f4291ad --- /dev/null +++ b/ngapp/src/app/dataservices/shared/connection-summary.model.spec.ts @@ -0,0 +1,74 @@ +import { ConnectionSummary } from "@dataservices/shared/connection-summary.model"; + +describe("ConnectionSummary", () => { + let connectionSummary: ConnectionSummary; + + beforeEach(() => { + connectionSummary = null; + }); + + it("should create", () => { + console.log("========== [ConnectionSummary] should create"); + connectionSummary = ConnectionSummary.create( + { + "connection": { + "keng__baseUri": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/", + "keng__id": "PgConn", + "keng__dataPath": "/tko:komodo/tko:workspace/admin/PgConn", + "keng__kType": "Connection", + "keng__hasChildren": true, + "dv__jndiName": "java:/postgresql-persistent-jq7wz", + "dv__driverName": "postgresql", + "dv__type": true, + "keng__properties": [ + { + "name": "description", + "value": "customer db on postgres" + }, + { + "name": "serviceCatalogSource", + "value": "postgresql-persistent-jq7wz" + } + ], + "keng___links": [ + { + "rel": "self", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/connections/PgConn" + }, + { + "rel": "parent", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/connections" + }, + { + "rel": "children", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/search%2Fadmin%2FPgConn" + } + ] + }, + "status": { + "connectionName": "PgConn", + "vdbState": "ACTIVE", + "schemaState": "ACTIVE", + "errors": [], + "schemaModelName": "pgconnschemamodel", + "schemaVdbName": "pgconnschemavdb", + "vdbName": "pgconnbtlconn" + } + } + ); + + expect(connectionSummary.getConnection().getId()).toEqual("PgConn"); + expect(connectionSummary.getConnection().getDescription()).toEqual("customer db on postgres"); + expect(connectionSummary.getConnection().getDriverName()).toEqual("postgresql"); + expect(connectionSummary.getConnection().getJndiName()).toEqual("java:/postgresql-persistent-jq7wz"); + expect(connectionSummary.getConnection().getServiceCatalogSourceName()).toEqual("postgresql-persistent-jq7wz"); + expect(connectionSummary.getConnection().getDataPath()).toEqual("/tko:komodo/tko:workspace/admin/PgConn"); + + expect(connectionSummary.getStatus().getConnectionName()).toEqual("PgConn"); + expect(connectionSummary.getStatus().getSchemaModelName()).toEqual("pgconnschemamodel"); + expect(connectionSummary.getStatus().getSchemaVdbName()).toEqual("pgconnschemavdb"); + expect(connectionSummary.getStatus().getServerVdbName()).toEqual("pgconnbtlconn"); + expect(connectionSummary.getStatus().getErrors()).toEqual([]); + }); + +}); diff --git a/ngapp/src/app/dataservices/shared/dataservice.model.spec.ts b/ngapp/src/app/dataservices/shared/dataservice.model.spec.ts new file mode 100644 index 00000000..433498f0 --- /dev/null +++ b/ngapp/src/app/dataservices/shared/dataservice.model.spec.ts @@ -0,0 +1,71 @@ +import { Dataservice } from "@dataservices/shared/dataservice.model"; +import { DeploymentState } from "@dataservices/shared/deployment-state.enum"; +import { PublishState } from "@dataservices/shared/publish-state.enum"; + +describe("Dataservice", () => { + let dataservice: Dataservice; + + beforeEach(() => { + dataservice = null; + }); + + it("should create", () => { + console.log("========== [Dataservice] should create"); + dataservice = Dataservice.create( + { + "keng__baseUri": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/", + "keng__id": "mongoVirtualization", + "keng__dataPath": "/tko:komodo/tko:workspace/admin/mongoVirtualization", + "keng__kType": "Dataservice", + "keng__hasChildren": true, + "serviceVdbName": "mongovirtualizationvdb", + "serviceVdbVersion": "1", + "serviceViewModel": "views", + "serviceViews": [ + "addressView", + "gradesView", + "restaurantsView" + ], + "serviceViewTables": [ + "mongoconnschemavdb.address", + "mongoconnschemavdb.grades", + "mongoconnschemavdb.restaurants" + ], + "connections": 0, + "drivers": 0, + "keng___links": [ + { + "rel": "self", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/dataservices/mongoVirtualization" + }, + { + "rel": "parent", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/dataservices" + }, + { + "rel": "children", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/xxx" + }, + { + "rel": "vdbs", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/yyy" + }, + { + "rel": "connections", + "href": "http://das-beetle-studio.192.168.42.154.nip.io/vdb-builder/v1/workspace/zzz" + } + ] + } + ); + + expect(dataservice.getId()).toEqual("mongoVirtualization"); + expect(dataservice.getServiceVdbName()).toEqual("mongovirtualizationvdb"); + expect(dataservice.getServiceVdbVersion()).toEqual("1"); + expect(dataservice.getServiceViewModel()).toEqual("views"); + expect(dataservice.getServiceViewTables().length).toEqual(3); + expect(dataservice.getServiceViewNames().length).toEqual(3); + expect(dataservice.getServiceDeploymentState()).toEqual(DeploymentState.LOADING); + expect(dataservice.getServicePublishState()).toEqual(PublishState.NOT_PUBLISHED); + }); + +}); diff --git a/ngapp/src/app/dataservices/shared/query-results.model.spec.ts b/ngapp/src/app/dataservices/shared/query-results.model.spec.ts new file mode 100644 index 00000000..d4c7e2a6 --- /dev/null +++ b/ngapp/src/app/dataservices/shared/query-results.model.spec.ts @@ -0,0 +1,200 @@ +import { QueryResults } from "@dataservices/shared/query-results.model"; + +describe("QueryResults", () => { + let queryResults: QueryResults; + + const employeeJson = { + "columns": [ + { + "name": "ssn", + "label": "ssn", + "type": "string" + }, + { + "name": "firstname", + "label": "firstname", + "type": "string" + }, + { + "name": "lastname", + "label": "lastname", + "type": "string" + }, + { + "name": "st_address", + "label": "st_address", + "type": "string" + }, + { + "name": "apt_number", + "label": "apt_number", + "type": "string" + }, + { + "name": "city", + "label": "city", + "type": "string" + }, + { + "name": "state", + "label": "state", + "type": "string" + }, + { + "name": "zipcode", + "label": "zipcode", + "type": "string" + }, + { + "name": "phone", + "label": "phone", + "type": "string" + } + ], + "rows": [ + { + "row": [ + "CST01002 ", + "Joseph", + "Smith", + "1234 Main Street", + "Apartment 56", + "New York", + "New York", + "10174", + "(646)555-1776" + ] + }, + { + "row": [ + "CST01003 ", + "Nicholas", + "Ferguson", + "202 Palomino Drive", + "", + "Pittsburgh", + "Pennsylvania", + "15071", + "(412)555-4327" + ] + }, + { + "row": [ + "CST01004 ", + "Jane", + "Aire", + "15 State Street", + "", + "Philadelphia", + "Pennsylvania", + "19154", + "(814)555-6789" + ] + }, + { + "row": [ + "CST01005 ", + "Charles", + "Jones", + "1819 Maple Street", + "Apartment 17F", + "Stratford", + "Connecticut", + "06614", + "(203)555-3947" + ] + }, + { + "row": [ + "CST01006 ", + "Virginia", + "Jefferson", + "1710 South 51st Street", + "Apartment 3245", + "New York", + "New York", + "10175", + "(718)555-2693" + ] + }, + { + "row": [ + "CST01007 ", + "Ralph", + "Bacon", + "57 Barn Swallow Avenue", + "", + "Charlotte", + "North Carolina", + "28205", + "(704)555-4576" + ] + }, + { + "row": [ + "CST01008 ", + "Bonnie", + "Dragon", + "88 Cinderella Lane", + "", + "Jacksonville", + "Florida", + "32225", + "(904)555-6514" + ] + }, + { + "row": [ + "CST01009 ", + "Herbert", + "Smith", + "12225 Waterfall Way", + "Building 100, Suite 9", + "Portland", + "Oregon", + "97220", + "(971)555-7803" + ] + }, + { + "row": [ + "CST01015 ", + "Jack", + "Corby", + "1 Lone Star Way", + "", + "Dallas", + "Texas", + "75231", + "(469)555-8023" + ] + }, + { + "row": [ + "CST01019 ", + "Robin", + "Evers", + "1814 Falcon Avenue", + "", + "Atlanta", + "Georgia", + "30355", + "(470)555-4390" + ] + } + ] + }; + + beforeEach(() => { + queryResults = null; + }); + + it("should create", () => { + console.log("========== [QueryResults] should create"); + queryResults = new QueryResults(employeeJson); + + expect(queryResults.getColumns().length).toEqual(9); + expect(queryResults.getRows().length).toEqual(10); + }); + +}); diff --git a/ngapp/src/app/dataservices/shared/vdb-status.model.spec.ts b/ngapp/src/app/dataservices/shared/vdb-status.model.spec.ts new file mode 100644 index 00000000..838c5e29 --- /dev/null +++ b/ngapp/src/app/dataservices/shared/vdb-status.model.spec.ts @@ -0,0 +1,33 @@ +import { VdbStatus } from "@dataservices/shared/vdb-status.model"; + +describe("VdbStatus", () => { + let vdbStatus: VdbStatus; + + beforeEach(() => { + vdbStatus = null; + }); + + it("should create", () => { + console.log("========== [VdbStatus] should create"); + vdbStatus = VdbStatus.create( + { + "name": "acctsVdb", + "deployedName": "acctsVdb-vdb.xml", + "version": "1", + "active": true, + "loading": false, + "failed": false, + "errors": [] + } + ); + + expect(vdbStatus.getName()).toEqual("acctsVdb"); + expect(vdbStatus.getDeployedName()).toEqual("acctsVdb-vdb.xml"); + expect(vdbStatus.getVersion()).toEqual("1"); + expect(vdbStatus.getErrors()).toEqual([]); + expect(vdbStatus.isActive()).toEqual(true); + expect(vdbStatus.isLoading()).toEqual(false); + expect(vdbStatus.isFailed()).toEqual(false); + }); + +}); diff --git a/ngapp/src/app/dataservices/shared/virtualization.model.spec.ts b/ngapp/src/app/dataservices/shared/virtualization.model.spec.ts new file mode 100644 index 00000000..65570c92 --- /dev/null +++ b/ngapp/src/app/dataservices/shared/virtualization.model.spec.ts @@ -0,0 +1,36 @@ +import { PublishState } from "@dataservices/shared/publish-state.enum"; +import { Virtualization } from "@dataservices/shared/virtualization.model"; + +describe("Virtualization", () => { + let virtualization: Virtualization; + + beforeEach(() => { + virtualization = null; + }); + + it("should create", () => { + console.log("========== [Virtualization] should create"); + virtualization = Virtualization.create( + { + "vdb_name": "acctsVdb", + "build_name": "acctsVdb-build-1", + "deployment_name": "acctsVdb-deployment-1", + "build_status": "RUNNING", /* NOTFOUND, BUILDING, DEPLOYING, RUNNING, FAILED, CANCELLED */ + "build_status_message": "Accounts VDB build was successful", + "namespace": "beetle-studio", + "last_updated": "2018-03-29T17:02:51.181Z", + "publishState": PublishState.PUBLISHED + } + ); + + expect(virtualization.getVdbName()).toEqual("acctsVdb"); + expect(virtualization.getBuildName()).toEqual("acctsVdb-build-1"); + expect(virtualization.getDeploymentName()).toEqual("acctsVdb-deployment-1"); + expect(virtualization.getBuildStatus()).toEqual("RUNNING"); + expect(virtualization.getBuildStatusMsg()).toEqual("Accounts VDB build was successful"); + expect(virtualization.getNamespace()).toEqual("beetle-studio"); + expect(virtualization.getLastUpdated()).toEqual("2018-03-29T17:02:51.181Z"); + expect(virtualization.getPublishState()).toEqual(PublishState.PUBLISHED); + }); + +});