Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
TTOOLS-404 Adds unit tests for models
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed May 18, 2018
1 parent 5659653 commit 5af312b
Show file tree
Hide file tree
Showing 10 changed files with 551 additions and 178 deletions.
35 changes: 35 additions & 0 deletions 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);
});

});
57 changes: 57 additions & 0 deletions 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");
});

});
@@ -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);
});

});
87 changes: 0 additions & 87 deletions ngapp/src/app/connections/shared/template-definition.model.ts

This file was deleted.

91 changes: 0 additions & 91 deletions ngapp/src/app/dataservices/shared/catalog-schema.model.ts

This file was deleted.

74 changes: 74 additions & 0 deletions 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([]);
});

});

0 comments on commit 5af312b

Please sign in to comment.