MIGRATE_TO_ORACLE: Developer tested!
diff --git a/deploy/db/02_create_tables_with_example_data.sql b/deploy/db/02_create_tables_with_example_data.sql index 979a88e..a793812 100644 --- a/deploy/db/02_create_tables_with_example_data.sql +++ b/deploy/db/02_create_tables_with_example_data.sql
@@ -103,20 +103,20 @@ OWNER TO CBD_SERVICE; GRANT ALL ON TABLE public.TBL_CONTACT TO CBD_SERVICE; -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ae3f2ec1-ccc5-4269-a48f-dd40e37fa14e', 'COM', 'company 1 (id=1)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'fc7f598b-0d51-46bb-9563-99851fe6a3ad', 'COM', 'company 2 (id=2)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '556b91be-6d57-432f-93ed-65604dd6e5cd', 'C_P', 'contact person 1 (id=3)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '116380e3-25c5-4179-b40a-8abebe10fe07', 'C_P', 'contact person 2 (id=4)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '7782179b-fb79-4370-8f71-f4c71470d006', 'I_P', 'internal person 1 (id=5)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '8963aa38-d021-4dc9-bd70-d3734ccd20c4', 'I_P', 'internal person 2 (id=6)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'c862d604-5766-43d6-a7e8-a4bac2bd01e1', 'E_P', 'external person 1 (id=7)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'fa3d981b-a7d6-4965-a623-cdbc69404153', 'E_P', 'external person 2 (id=8)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ceba21e9-e685-483b-840e-ad167860a696', 'COM', 'anonymous company A (id=9)', true ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '7889c814-9752-4e4e-a9fe-b46f36a38ccd', 'COM', 'anonymous company B (id=10)', true ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '618a01a3-f348-44cc-9ddd-c9df946b0212', 'C_P', 'anoymous contact person A1 (id=11)', true ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '4ed82474-3878-457a-baef-c28b8e486f25', 'C_P', 'anoymous contact persion A2 (id=12)', true ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '8fe41b90-d10c-4a70-8fde-0990286ad3c6', 'I_P', 'internal person 3 (id=13)', null ); -INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ab804610-d6a4-4803-a4a1-3f6cb742b2a4', 'I_P', 'internal person 4 (id=14)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ae3f2ec1-ccc5-4269-a48f-dd40e37fa14e', '4CO', 'company 1 (id=1)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'fc7f598b-0d51-46bb-9563-99851fe6a3ad', '4CO', 'company 2 (id=2)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '556b91be-6d57-432f-93ed-65604dd6e5cd', '1CP', 'contact person 1 (id=3)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '116380e3-25c5-4179-b40a-8abebe10fe07', '1CP', 'contact person 2 (id=4)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '7782179b-fb79-4370-8f71-f4c71470d006', '3IP', 'internal person 1 (id=5)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '8963aa38-d021-4dc9-bd70-d3734ccd20c4', '3IP', 'internal person 2 (id=6)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'c862d604-5766-43d6-a7e8-a4bac2bd01e1', '2EP', 'external person 1 (id=7)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'fa3d981b-a7d6-4965-a623-cdbc69404153', '2EP', 'external person 2 (id=8)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ceba21e9-e685-483b-840e-ad167860a696', '4CO', 'anonymous company A (id=9)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '7889c814-9752-4e4e-a9fe-b46f36a38ccd', '4CO', 'anonymous company B (id=10)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '618a01a3-f348-44cc-9ddd-c9df946b0212', '1CP', 'anoymous contact person A1 (id=11)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '4ed82474-3878-457a-baef-c28b8e486f25', '1CP', 'anoymous contact persion A2 (id=12)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '8fe41b90-d10c-4a70-8fde-0990286ad3c6', '3IP', 'internal person 3 (id=13)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ab804610-d6a4-4803-a4a1-3f6cb742b2a4', '3IP', 'internal person 4 (id=14)', null ); CREATE UNIQUE INDEX idx_tbl_contact_contact_type ON public.TBL_CONTACT ( ID ASC ); @@ -483,7 +483,7 @@ FK_SALUTATION_ID bigint, FK_REF_PERSON_TYPE_ID bigint, DEPARTMENT character varying(255), - UID character varying(255), + UID_IDENT character varying(255), USER_REF character varying(255), FK_CONTACT_ID bigint NOT NULL, CONSTRAINT TBL_INTERNAL_PERSON_PKEY PRIMARY KEY (ID), @@ -501,13 +501,13 @@ OWNER TO CBD_SERVICE; GRANT ALL ON TABLE public.TBL_INTERNAL_PERSON TO CBD_SERVICE; -CREATE UNIQUE INDEX idx_tbl_internal_person_uid ON public.TBL_INTERNAL_PERSON ( UID ASC ); +CREATE UNIQUE INDEX idx_tbl_internal_person_uid ON public.TBL_INTERNAL_PERSON ( UID_IDENT ASC ); CREATE UNIQUE INDEX idx_tbl_internal_person_user_ref ON public.TBL_INTERNAL_PERSON ( USER_REF ASC ); -INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID, USER_REF, FK_CONTACT_ID) VALUES ( 'Pauline', 'Freudenberg', 'B.Sc.', 1, 1,'Abteilung Rechnungsstellung', '66cd78c3-6716-4ab3-b834-a199fc796b88', 'PFREUD', 5); -INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID, USER_REF, FK_CONTACT_ID) VALUES ( 'Bernhardt', 'Iffland', '', 2, 2,'Kreativ', '4124e4e7-3488-4492-bf39-75e6a23a1c1a', 'BIFFL', 6); -INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID, USER_REF, FK_CONTACT_ID) VALUES ( 'Horatio', 'Hornblower', 'Capt.', 1, 2,'Royal Navy', 'hhornblo', 'HORNB', 13); -INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID, USER_REF, FK_CONTACT_ID) VALUES ( 'Cornelius', 'Buckley', '', 1, 2,'Royal Navy', null, 'BUCKC', 14); +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Pauline', 'Freudenberg', 'B.Sc.', 1, 1,'Abteilung Rechnungsstellung', '66cd78c3-6716-4ab3-b834-a199fc796b88', 'PFREUD', 5); +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Bernhardt', 'Iffland', '', 2, 2,'Kreativ', '4124e4e7-3488-4492-bf39-75e6a23a1c1a', 'BIFFL', 6); +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Horatio', 'Hornblower', 'Capt.', 1, 2,'Royal Navy', 'hhornblo', 'HORNB', 13); +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Cornelius', 'Buckley', '', 1, 2,'Royal Navy', null, 'BUCKC', 14); -- --------------------------------------------- -- TABLE TBL_ASSIGNMENT_MODUL_CONTACT -- ---------------------------------------------
diff --git a/deploy/db/oracle/01_drop_db.sql b/deploy/db/oracle/01_drop_db.sql new file mode 100644 index 0000000..9bd16e0 --- /dev/null +++ b/deploy/db/oracle/01_drop_db.sql
@@ -0,0 +1,55 @@ +----------------------------------------------------------------------------------- +-- ******************************************************************************* +-- * Copyright (c) 2019 Contributors to the Eclipse Foundation +-- * +-- * See the NOTICE file(s) distributed with this work for additional +-- * information regarding copyright ownership. +-- * +-- * This program and the accompanying materials are made available under the +-- * terms of the Eclipse Public License v. 2.0 which is available at +-- * http://www.eclipse.org/legal/epl-2.0. +-- * +-- * SPDX-License-Identifier: EPL-2.0 +-- ******************************************************************************* +----------------------------------------------------------------------------------- + +DROP VIEW VW_DETAILED_CONTACT; +DROP VIEW VW_GENERAL_CONTACT; + +DROP TABLE TBL_ASSIGNMENT_MODUL_CONTACT; +DROP SEQUENCE TBL_ASSIGN_MODUL_CNTCT_ID_SEQ; + +DROP TABLE TBL_INTERNAL_PERSON; +DROP SEQUENCE TBL_INTERNAL_PERSON_ID_SEQ; + +DROP TABLE TBL_EXTERNAL_PERSON; +DROP SEQUENCE TBL_EXTERNAL_PERSON_ID_SEQ; + +DROP TABLE TBL_CONTACT_PERSON; +DROP SEQUENCE TBL_CONTACT_PERSON_ID_SEQ; + +DROP TABLE TBL_COMPANY; +DROP SEQUENCE TBL_COMPANY_ID_SEQ; + +DROP TABLE TBL_COMMUNICATION; +DROP SEQUENCE TBL_COMMUNICATION_ID_SEQ; + +DROP TABLE TBL_ADDRESS; +DROP SEQUENCE TBL_ADDRESS_ID_SEQ; + +DROP TABLE REF_SALUTATION; +DROP SEQUENCE REF_SALUTATION_ID_SEQ; + +DROP TABLE REF_COMMUNICATION_TYPE; +DROP SEQUENCE REF_COMMUNICATION_TYPE_ID_SEQ; + +DROP TABLE REF_PERSON_TYPE; +DROP SEQUENCE REF_PERSON_TYPE_ID_SEQ; + +DROP TABLE REF_ADDRESS_TYPE; +DROP SEQUENCE REF_ADDRESS_TYPE_ID_SEQ; + +DROP TABLE TBL_CONTACT; +DROP SEQUENCE TBL_CONTACT_ID_SEQ; + +DROP TABLE VERSION;
diff --git a/deploy/db/oracle/02_create_tables_with_example_data.sql b/deploy/db/oracle/02_create_tables_with_example_data.sql new file mode 100644 index 0000000..1c1531a --- /dev/null +++ b/deploy/db/oracle/02_create_tables_with_example_data.sql
@@ -0,0 +1,655 @@ + +-- --------------------------------------------- +-- TABLE VERSION +-- --------------------------------------------- +-- TABLE: PUBLIC.REF_VERSION +CREATE TABLE VERSION +( + "ID" INTEGER NOT NULL, + "VERSION" VARCHAR2(500) NOT NULL, + CONSTRAINT VERSION_PKEY PRIMARY KEY ("ID") +); + +INSERT INTO VERSION (ID, VERSION) VALUES ( 1, '1.0-ORA' ); + + +-- --------------------------------------------- +-- TABLE TBL_CONTACT +-- --------------------------------------------- + +CREATE SEQUENCE TBL_CONTACT_ID_SEQ + INCREMENT BY 1; + +CREATE TABLE TBL_CONTACT +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "CONTACT_TYPE" VARCHAR2(3), + "NOTE" VARCHAR2(255), + "ANONYMIZED" NUMBER, + CONSTRAINT TBL_CONTACT_PKEY PRIMARY KEY ("ID") +); + +CREATE OR REPLACE TRIGGER "TBL_CONTACT_BIR" +BEFORE INSERT ON TBL_CONTACT +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_CONTACT_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_CONTACT_BIR" ENABLE; + + +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('ae3f2ec1-ccc5-4269-a48f-dd40e37fa14e','-','')), '4CO', 'company 1 (id=1)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('fc7f598b-0d51-46bb-9563-99851fe6a3ad','-','')), '4CO', 'company 2 (id=2)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('556b91be-6d57-432f-93ed-65604dd6e5cd','-','')), '1CP', 'contact person 1 (id=3)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('116380e3-25c5-4179-b40a-8abebe10fe07','-','')), '1CP', 'contact person 2 (id=4)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('7782179b-fb79-4370-8f71-f4c71470d006','-','')), '3IP', 'internal person 1 (id=5)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('8963aa38-d021-4dc9-bd70-d3734ccd20c4','-','')), '3IP', 'internal person 2 (id=6)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('c862d604-5766-43d6-a7e8-a4bac2bd01e1','-','')), '2EP', 'external person 1 (id=7)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('fa3d981b-a7d6-4965-a623-cdbc69404153','-','')), '2EP', 'external person 2 (id=8)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('ceba21e9-e685-483b-840e-ad167860a696','-','')), '4CO', 'anonymous company A (id=9)', 1 ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('7889c814-9752-4e4e-a9fe-b46f36a38ccd','-','')), '4CO', 'anonymous company B (id=10)', 1 ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('618a01a3-f348-44cc-9ddd-c9df946b0212','-','')), '1CP', 'anoymous contact person A1 (id=11)', 1 ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('4ed82474-3878-457a-baef-c28b8e486f25','-','')), '1CP', 'anoymous contact persion A2 (id=12)', 1 ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('8fe41b90-d10c-4a70-8fde-0990286ad3c6','-','')), '3IP', 'internal person 3 (id=13)', null ); +INSERT INTO "TBL_CONTACT" ("UUID", "CONTACT_TYPE", "NOTE", "ANONYMIZED") VALUES ( hextoraw(replace('ab804610-d6a4-4803-a4a1-3f6cb742b2a4','-','')), '3IP', 'internal person 4 (id=14)', null ); + + +CREATE UNIQUE INDEX IDX_CNTCT_UUID ON TBL_CONTACT (UUID); +CREATE INDEX IDX_CNTCT_ANONYM ON TBL_CONTACT (ANONYMIZED); + + +-- --------------------------------------------- +-- TABLE REF_ADDRESS_TYPE +-- --------------------------------------------- +CREATE SEQUENCE REF_ADDRESS_TYPE_ID_SEQ + INCREMENT BY 1; + +CREATE TABLE REF_ADDRESS_TYPE +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "TYPE" VARCHAR2(30), + "DESCRIPTION" VARCHAR2(255), + CONSTRAINT REF_ADDRESS_TYPE_PKEY PRIMARY KEY ("ID") +); + +CREATE OR REPLACE TRIGGER "REF_ADDRESS_TYPE_BIR" +BEFORE INSERT ON REF_ADDRESS_TYPE +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT REF_ADDRESS_TYPE_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "REF_ADDRESS_TYPE_BIR" ENABLE; + +CREATE UNIQUE INDEX IDX_REF_ADDRESS_TYPE_UUID ON REF_ADDRESS_TYPE ( UUID ASC ); + +INSERT INTO REF_ADDRESS_TYPE ("UUID", "TYPE", "DESCRIPTION") VALUES ( hextoraw(replace('3802e681-9396-434e-b19c-5fedcec40ba7','-','')), 'Geschäftsadresse', 'Adresse des Hauptfirmensitzes' ); +INSERT INTO REF_ADDRESS_TYPE ("UUID", "TYPE", "DESCRIPTION") VALUES ( hextoraw(replace('f43ed6ac-9e7a-40f6-acc9-ec6b73eebf79','-','')), 'Privatadresse', 'private Anschrift' ); +INSERT INTO REF_ADDRESS_TYPE ("UUID", "TYPE", "DESCRIPTION") VALUES ( hextoraw(replace('70fd0811-f674-4f3a-96a7-7ae29fc95188','-','')), 'Lieferadresse', 'Adresse für Lieferungen' ); + + +-- --------------------------------------------- +-- TABLE REF_PERSON_TYPE +-- --------------------------------------------- +CREATE SEQUENCE REF_PERSON_TYPE_ID_SEQ + INCREMENT BY 1; + +CREATE TABLE REF_PERSON_TYPE +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "TYPE" VARCHAR2(30), + "DESCRIPTION" VARCHAR2(255), + CONSTRAINT REF_PERSON_TYPE_PKEY PRIMARY KEY (ID) +); + +CREATE OR REPLACE TRIGGER "REF_PERSON_TYPE_BIR" +BEFORE INSERT ON REF_PERSON_TYPE +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT REF_PERSON_TYPE_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "REF_PERSON_TYPE_BIR" ENABLE; + +CREATE UNIQUE INDEX IDX_REF_PERSON_TYPE_UUID ON REF_PERSON_TYPE ( UUID ASC ); + +INSERT INTO REF_PERSON_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( hextoraw(replace('47ce68b7-6d44-453e-b421-19020fd791b5','-','')), 'Rechtsanwalt', '' ); +INSERT INTO REF_PERSON_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( hextoraw(replace('a7522c72-14d0-4e9d-afe3-bfcb3ffbec10','-','')), 'Geschäftsführer', '' ); +INSERT INTO REF_PERSON_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( hextoraw(replace('2eb4885e-7363-4918-90ed-b7d5d84cfd3f','-','')), 'Rechnungsempfänger', 'Person, der Rechnungen zukommen' ); + + +-- --------------------------------------------- +-- TABLE REF_COMMUNICATION_TYPE +-- --------------------------------------------- +CREATE SEQUENCE REF_COMMUNICATION_TYPE_ID_SEQ + INCREMENT BY 1; + + +CREATE TABLE REF_COMMUNICATION_TYPE +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "TYPE" VARCHAR2(30), + "DESCRIPTION" VARCHAR2(255), + "TYPE_EMAIL" NUMBER, + CONSTRAINT REF_COMMUNICATION_TYPE_PKEY PRIMARY KEY (ID) +); + +CREATE OR REPLACE TRIGGER "REF_COMMUNICATION_TYPE_BIR" +BEFORE INSERT ON REF_COMMUNICATION_TYPE +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT REF_COMMUNICATION_TYPE_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "REF_COMMUNICATION_TYPE_BIR" ENABLE; + + +CREATE UNIQUE INDEX idx_ref_comm_type_uuid ON REF_COMMUNICATION_TYPE ( UUID ASC ); + +INSERT INTO REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( hextoraw(replace('4757ca3a-72c2-4f13-a2f6-ce092e3eadf4','-','')), 'E-Mail', 'E-Mail Adresse', 1 ); +INSERT INTO REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( hextoraw(replace('77028572-ff57-4c1d-999a-78fa3fcbc1cd','-','')), 'Festnetz', '', 0 ); +INSERT INTO REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( hextoraw(replace('f7d5b343-00c2-4d7f-8e03-009aad3d90f7','-','')), 'Mobil', '', 0 ); +INSERT INTO REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( hextoraw(replace('2bfe40f9-c4eb-4d2e-855f-6b0883912846','-','')), 'Fax', '', 0 ); +INSERT INTO REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( hextoraw(replace('d00d1a61-c8e7-43b2-959f-66e986731441','-','')), 'WhatsApp', '', 0 ); + +-- --------------------------------------------- +-- TABLE REF_SALUTATION +-- --------------------------------------------- +CREATE SEQUENCE REF_SALUTATION_ID_SEQ + INCREMENT BY 1; + +CREATE TABLE REF_SALUTATION +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "TYPE" VARCHAR2(30), + "DESCRIPTION" VARCHAR2(255), + CONSTRAINT REF_SALUTATION_PKEY PRIMARY KEY (ID) +); + +CREATE OR REPLACE TRIGGER "REF_SALUTATION_BIR" +BEFORE INSERT ON REF_SALUTATION +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT REF_SALUTATION_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "REF_SALUTATION_BIR" ENABLE; + + +CREATE UNIQUE INDEX idx_ref_salutation_uuid ON REF_SALUTATION ( UUID ASC ); + +INSERT INTO REF_SALUTATION (UUID, TYPE, DESCRIPTION) VALUES ( hextoraw(replace('90119f18-5562-425d-9a36-3dd58ea125e5','-','')), 'Herr', 'Anrede männlich' ); +INSERT INTO REF_SALUTATION (UUID, TYPE, DESCRIPTION) VALUES ( hextoraw(replace('4e873baa-e4f5-4585-8b16-2db8fac66538','-','')), 'Frau', 'Anrede weiblich' ); + + +-- --------------------------------------------- +-- TABLE TBL_ADDRESS +-- --------------------------------------------- +CREATE SEQUENCE TBL_ADDRESS_ID_SEQ + INCREMENT BY 1; + +CREATE TABLE TBL_ADDRESS +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "FK_CONTACT_ID" INTEGER NOT NULL, + "FK_ADDRESS_TYPE" INTEGER, + "IS_MAIN_ADDRESS" NUMBER, + "POSTCODE" VARCHAR2(30), + "COMMUNITY" VARCHAR2(255), + "COMMUNITY_SUFFIX" VARCHAR2(255), + "STREET" VARCHAR2(255), + "HOUSENUMBER" VARCHAR2(30), + "WGS_84_ZONE" VARCHAR2(255), + "LATITUDE" VARCHAR2(255), + "LONGITUDE" VARCHAR2(255), + "URL_MAP" VARCHAR2(255), + "NOTE" VARCHAR2(255), + + CONSTRAINT TBL_ADDRESS_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_ADDRESS__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES TBL_CONTACT(ID), + CONSTRAINT TBL_ADDRESS_ADDR_TYPE_FKEY FOREIGN KEY (FK_ADDRESS_TYPE) + REFERENCES REF_ADDRESS_TYPE (ID) +); + +CREATE OR REPLACE TRIGGER "TBL_ADDRESS_BIR" +BEFORE INSERT ON TBL_ADDRESS +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_ADDRESS_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_ADDRESS_BIR" ENABLE; + + +CREATE UNIQUE INDEX idx_tbl_address_uuid ON TBL_ADDRESS ( UUID ASC ); + +INSERT INTO TBL_ADDRESS (UUID, FK_CONTACT_ID, FK_ADDRESS_TYPE, IS_MAIN_ADDRESS, POSTCODE, COMMUNITY, COMMUNITY_SUFFIX, STREET, HOUSENUMBER, WGS_84_ZONE, LATITUDE, LONGITUDE, URL_MAP, NOTE) VALUES ( hextoraw(replace('37e800fe-64f0-4834-8b83-8453cbb936a5','-','')), 2, 1, 1, '12345', 'Heringsdorf','', 'Flunderweg', '5', '', '53 NL', '3 WB','www.xyz', 'nur über Seeweg erreichbar'); +INSERT INTO TBL_ADDRESS (UUID, FK_CONTACT_ID, FK_ADDRESS_TYPE, IS_MAIN_ADDRESS, POSTCODE, COMMUNITY, COMMUNITY_SUFFIX, STREET, HOUSENUMBER, WGS_84_ZONE, LATITUDE, LONGITUDE, URL_MAP, NOTE) VALUES ( hextoraw(replace('8a1202ae-2532-474e-8367-a1f0e13e9fbd','-','')), 1, 2, 0, '67890', 'Stralsund','', 'Schollendamm', '18', '', '53 N', '2 WB','www.xyz', 'Hochwassergefahr'); + + +-- --------------------------------------------- +-- TABLE TBL_COMMUNICATION +-- --------------------------------------------- +CREATE SEQUENCE TBL_COMMUNICATION_ID_SEQ + INCREMENT BY 1; + +CREATE TABLE TBL_COMMUNICATION +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "FK_CONTACT_ID" INTEGER NOT NULL, + "FK_COMMUNICATION_TYPE" INTEGER, + "COMMUNICATION_DATA" VARCHAR2(1024), + "NOTE" VARCHAR2(255), + + CONSTRAINT TBL_COMMUNICATION_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_COMM__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES TBL_CONTACT(ID), + CONSTRAINT TBL_COMM__COMM_TYPE_ID_FKEY FOREIGN KEY (FK_COMMUNICATION_TYPE) + REFERENCES REF_COMMUNICATION_TYPE (ID) +); + +CREATE OR REPLACE TRIGGER "TBL_COMMUNICATION_BIR" +BEFORE INSERT ON TBL_COMMUNICATION +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_COMMUNICATION_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_COMMUNICATION_BIR" ENABLE; + + +CREATE UNIQUE INDEX idx_tbl_communication_uuid ON TBL_COMMUNICATION ( UUID ASC ); + +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('25f6d7cc-b168-4dd5-a36d-6f14b2f956e9','-','')), 2, 2, 'bitte melden Sie sich bei uns', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('a5fa380e-8f33-4ea7-9416-e03d11b91cae','-','')), 1, 3, 'bitte melden zwecks Terminabstimmung', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('c0dcef80-ca07-48b7-a3ed-2c99c4388928','-','')), 1, 1, 'info@bigbang.com', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('d19d9e10-d2dd-4383-84ec-2fe96421c0a3','-','')), 2, 1, 'info@pharmapeekltd.com', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('234b63e4-d8db-48ab-899f-0320903c01af','-','')), 3, 1, 'reinbold.tab@pharmapeek.com', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('11e25c02-de00-430d-b6cd-f02f7c60e026','-','')), 5, 1, 'PaulineF@gmx.net', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('9ca29c3b-e189-4ce9-9401-15001c769627','-','')), 6, 1, 'mo@gmail.com', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('05505b1a-61df-45c0-b006-64165cbadfa2','-','')), 7, 1, 'MGruebelSport@fogger.mil', 'Info...'); +INSERT INTO TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( hextoraw(replace('b52dabaf-d156-4fd0-a07c-510673112a15','-','')), 8, 1, 'Mini.osterbrink@yahoo.ie', 'Info...'); + +-- --------------------------------------------- +-- TABLE TBL_COMPANY +-- --------------------------------------------- +CREATE SEQUENCE TBL_COMPANY_ID_SEQ + INCREMENT BY 1; + + +CREATE TABLE TBL_COMPANY +( + "ID" INTEGER NOT NULL, + "COMPANY_NAME" VARCHAR2(255), + "COMPANY_TYPE" VARCHAR2(30), + "HR_NUMBER" VARCHAR2(255), + "FK_CONTACT_ID" INTEGER NOT NULL, + CONSTRAINT TBL_COMPANY_PKEY PRIMARY KEY (id), + CONSTRAINT TBL_COMPANY__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES TBL_CONTACT(ID) +); + +CREATE OR REPLACE TRIGGER "TBL_COMPANY_BIR" +BEFORE INSERT ON TBL_COMPANY +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_COMPANY_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_COMPANY_BIR" ENABLE; + + +INSERT INTO TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( 'BigBang Logistic', 'Logistik', '123', 1 ); +INSERT INTO TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( 'Pharma Peek', 'Pharma', '345', 2 ); +INSERT INTO TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( '***', '***', null, 9 ); +INSERT INTO TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( '***', '***', null, 10 ); + + +-- --------------------------------------------- +-- TABLE TBL_CONTACT_PERSON +-- --------------------------------------------- +CREATE SEQUENCE TBL_CONTACT_PERSON_ID_SEQ + INCREMENT BY 1; + + +CREATE TABLE TBL_CONTACT_PERSON +( + "ID" INTEGER NOT NULL, + "FIRST_NAME" VARCHAR2(255), + "LAST_NAME" VARCHAR2(255), + "TITLE" VARCHAR2(255), + "FK_SALUTATION_ID" INTEGER, + "FK_REF_PERSON_TYPE_ID" INTEGER NULL, + "FK_CONTACT_ID" INTEGER NOT NULL, + "FK_COMPANY_ID" INTEGER NOT NULL, + CONSTRAINT TBL_CONTACT_PERSON_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_CP__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES TBL_CONTACT (ID), + CONSTRAINT TBL_CP__PERSON_TYPE_ID_FKEY FOREIGN KEY (FK_REF_PERSON_TYPE_ID) + REFERENCES REF_PERSON_TYPE (ID), + CONSTRAINT TBL_CP__SALUTATION_ID_FKEY FOREIGN KEY (FK_SALUTATION_ID) + REFERENCES REF_SALUTATION (ID), + CONSTRAINT TBL_CP__COMPANY_ID_FKEY FOREIGN KEY (FK_COMPANY_ID) + REFERENCES TBL_COMPANY (ID) +); + +CREATE OR REPLACE TRIGGER "TBL_CONTACT_PERSON_BIR" +BEFORE INSERT ON TBL_CONTACT_PERSON +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_CONTACT_PERSON_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_CONTACT_PERSON_BIR" ENABLE; + + +INSERT INTO TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( 'Tabea', 'Reinebold', 'Dr.', 2, 1, 3, 2); +INSERT INTO TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( 'Jan', 'Wacker', '', 1, 1, 4, 2); +INSERT INTO TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( '***', '***', null, null, null, 11, 3); +INSERT INTO TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( '***', '***', null, null, null, 12, 2); + +-- --------------------------------------------- +-- TABLE TBL_EXTERNAL_PERSON +-- --------------------------------------------- +CREATE SEQUENCE TBL_EXTERNAL_PERSON_ID_SEQ + INCREMENT BY 1; + + +CREATE TABLE TBL_EXTERNAL_PERSON +( + "ID" INTEGER NOT NULL, + "FIRST_NAME" VARCHAR2(255), + "LAST_NAME" VARCHAR2(255), + "TITLE" VARCHAR2(255), + "FK_SALUTATION_ID" INTEGER, + "FK_REF_PERSON_TYPE_ID" INTEGER, + "FK_CONTACT_ID" INTEGER NOT NULL, + CONSTRAINT TBL_EXTERNAL_PERSON_PKEY PRIMARY KEY (id), + CONSTRAINT TBL_EP__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES TBL_CONTACT (ID), + CONSTRAINT TBL_EP__SALUTATION_ID_FKEY FOREIGN KEY (FK_SALUTATION_ID) + REFERENCES REF_SALUTATION (ID), + CONSTRAINT TBL_EP__PERSON_TYPE_ID_FKEY FOREIGN KEY (FK_REF_PERSON_TYPE_ID) + REFERENCES REF_PERSON_TYPE (ID) +); + +CREATE OR REPLACE TRIGGER "TBL_EXTERNAL_PERSON_BIR" +BEFORE INSERT ON TBL_EXTERNAL_PERSON +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_EXTERNAL_PERSON_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_EXTERNAL_PERSON_BIR" ENABLE; + + +INSERT INTO TBL_EXTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID) VALUES ( 'Monica', 'Grübel', 'Dipl.-Sportlehrerin', 2, 1, 7); +INSERT INTO TBL_EXTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID) VALUES ( 'Maurice', 'Fürstenberg', 'B.A.', 2, 2, 8); + + +-- --------------------------------------------- +-- TABLE TBL_INTERNAL_PERSON +-- --------------------------------------------- +CREATE SEQUENCE TBL_INTERNAL_PERSON_ID_SEQ + INCREMENT BY 1; + +CREATE TABLE TBL_INTERNAL_PERSON +( + "ID" INTEGER NOT NULL, + "FIRST_NAME" VARCHAR2(255), + "LAST_NAME" VARCHAR2(255), + "TITLE" VARCHAR2(255), + "FK_SALUTATION_ID" INTEGER, + "FK_REF_PERSON_TYPE_ID" INTEGER, + "DEPARTMENT" VARCHAR2(255), + "UID_IDENT" VARCHAR2(255), + "USER_REF" VARCHAR2(255), + "FK_CONTACT_ID" INTEGER NOT NULL, + CONSTRAINT TBL_INTERNAL_PERSON_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_IP__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES TBL_CONTACT (ID), + CONSTRAINT TBL_IP__SALUTATION_ID_FKEY FOREIGN KEY (FK_SALUTATION_ID) + REFERENCES REF_SALUTATION (ID), + CONSTRAINT TBL_IP__PERSON_TYPE_ID_FKEY FOREIGN KEY (FK_REF_PERSON_TYPE_ID) + REFERENCES REF_PERSON_TYPE (ID) +); + +CREATE OR REPLACE TRIGGER "TBL_INTERNAL_PERSON_BIR" +BEFORE INSERT ON TBL_INTERNAL_PERSON +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_INTERNAL_PERSON_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_INTERNAL_PERSON_BIR" ENABLE; + + +CREATE UNIQUE INDEX idx_tbl_internal_person_uid ON TBL_INTERNAL_PERSON ( "UID_IDENT" ASC ); +CREATE UNIQUE INDEX idx_tbl_ip_user_ref ON TBL_INTERNAL_PERSON ( "USER_REF" ASC ); + +INSERT INTO TBL_INTERNAL_PERSON ("FIRST_NAME", "LAST_NAME", "TITLE", "FK_SALUTATION_ID", "FK_REF_PERSON_TYPE_ID", "DEPARTMENT", "UID_IDENT", "USER_REF", "FK_CONTACT_ID") VALUES ( 'Pauline', 'Freudenberg', 'B.Sc.', 1, 1,'Abteilung Rechnungsstellung', '66cd78c3-6716-4ab3-b834-a199fc796b88', 'PFREUD', 5); +INSERT INTO TBL_INTERNAL_PERSON ("FIRST_NAME", "LAST_NAME", "TITLE", "FK_SALUTATION_ID", "FK_REF_PERSON_TYPE_ID", "DEPARTMENT", "UID_IDENT", "USER_REF", "FK_CONTACT_ID") VALUES ( 'Bernhardt', 'Iffland', '', 2, 2,'Kreativ', '4124e4e7-3488-4492-bf39-75e6a23a1c1a', 'BIFFL', 6); +INSERT INTO TBL_INTERNAL_PERSON ("FIRST_NAME", "LAST_NAME", "TITLE", "FK_SALUTATION_ID", "FK_REF_PERSON_TYPE_ID", "DEPARTMENT", "UID_IDENT", "USER_REF", "FK_CONTACT_ID") VALUES ( 'Horatio', 'Hornblower', 'Capt.', 1, 2,'Royal Navy', 'hhornblo', 'HORNB', 13); +INSERT INTO TBL_INTERNAL_PERSON ("FIRST_NAME", "LAST_NAME", "TITLE", "FK_SALUTATION_ID", "FK_REF_PERSON_TYPE_ID", "DEPARTMENT", "UID_IDENT", "USER_REF", "FK_CONTACT_ID") VALUES ( 'Cornelius', 'Buckley', '', 1, 2,'Royal Navy', null, 'BUCKC', 14); +-- --------------------------------------------- +-- TABLE TBL_ASSIGNMENT_MODUL_CONTACT +-- --------------------------------------------- +CREATE SEQUENCE TBL_ASSIGN_MODUL_CNTCT_ID_SEQ + INCREMENT BY 1; + + +CREATE TABLE TBL_ASSIGNMENT_MODUL_CONTACT +( + "ID" INTEGER NOT NULL, + "UUID" RAW(16) NOT NULL, + "FK_CONTACT_ID" INTEGER NOT NULL, + "MODUL_NAME" VARCHAR2(255), + "ASSIGNMENT_DATE" timestamp, + "EXPIRING_DATE" timestamp, + "DELETION_LOCK_UNTIL" timestamp, + "ASSIGNMENT_NOTE" VARCHAR2(2048), + CONSTRAINT TBL_ASS_MOD_CONTACT_PKEY PRIMARY KEY (id), + CONSTRAINT TBL_ASS_MOD_CONTACT_ID_FKEY FOREIGN KEY (fk_contact_id) + REFERENCES TBL_CONTACT (ID) +); + +CREATE OR REPLACE TRIGGER "TBL_ASSIGN_MODUL_CNTCT_BIR" +BEFORE INSERT ON TBL_ASSIGNMENT_MODUL_CONTACT +FOR EACH ROW + WHEN (NEW."ID" IS NULL) BEGIN + SELECT TBL_ASSIGN_MODUL_CNTCT_ID_SEQ.NEXTVAL + INTO :NEW."ID" + FROM DUAL; +END; +/ +ALTER TRIGGER "TBL_ASSIGN_MODUL_CNTCT_BIR" ENABLE; + + +INSERT INTO tbl_assignment_modul_contact(uuid, fk_contact_id, modul_name, assignment_date, expiring_date, deletion_lock_until, assignment_note) VALUES ( hextoraw(replace('dfc2979c-40e3-11ea-b77f-2e728ce88125','-','')), 1, 'Betriebstagebuch', CURRENT_TIMESTAMP, null, null, 'seit Januar zugeordnet'); +INSERT INTO tbl_assignment_modul_contact(uuid, fk_contact_id, modul_name, assignment_date, expiring_date, deletion_lock_until, assignment_note) VALUES ( hextoraw(replace('4009bce2-40e5-11ea-b77f-2e728ce88125','-','')), 1, 'Störinfos', CURRENT_TIMESTAMP, null, null, 'seit Februar zugeordnet'); + +-- ------------------------------------- +-- VIEWS ------------------------------- +-- ------------------------------------- +CREATE VIEW VW_GENERAL_CONTACT +AS +SELECT g.id, + c.uuid, + g.name, + c.contact_type, + g.fk_contact_id, + g.company_name, + g.company_type, + g.company_id, + g.fk_salutation_id, + g.fk_ref_person_type_id, + g.title, + g.first_name, + g.last_name, + g.department, + c.note, + c.anonymized +FROM tbl_contact c +JOIN ( + +SELECT company.id, + company_name as name, + fk_contact_id, + company_name, + company_type, + cntct.uuid as company_id, + null as fk_salutation_id, + null as fk_ref_person_type_id, + null as title, + null as first_name, + null as last_name, + null as department +FROM tbl_company company +JOIN tbl_contact cntct ON company.fk_contact_id = cntct.id + +UNION + +SELECT p.id, + COALESCE(p.last_name, '') + || CASE WHEN LENGTH(COALESCE(p.last_name, '')) > 0 AND LENGTH(COALESCE(p.first_name, '')) > 0 THEN ', ' ELSE '' END + || COALESCE(p.first_name,'') || ' [' || COALESCE(c.company_name, '') || ']' as name, + p.fk_contact_id, + c.company_name, + c.company_type, + company_contact.uuid as company_id, + p.fk_salutation_id, + p.fk_ref_person_type_id, + p.title, + p.first_name, + p.last_name, + null as department +FROM tbl_contact_person p +JOIN tbl_company c ON c.id = p.fk_company_id +JOIN tbl_contact company_contact ON c.fk_contact_id = company_contact.id + +UNION + +SELECT id, + COALESCE(last_name, '') + || CASE WHEN LENGTH(COALESCE(last_name, '')) > 0 AND LENGTH(COALESCE(first_name, '')) > 0 THEN ', ' ELSE '' END + || COALESCE(first_name, '') as name, + fk_contact_id, + null as company_name, + null as company_type, + null as company_id, + fk_salutation_id, + fk_ref_person_type_id, + title, + first_name, + last_name, + department +FROM tbl_internal_person + +UNION + +SELECT id, + COALESCE(last_name, '') + || CASE WHEN LENGTH(COALESCE(last_name, '')) > 0 AND LENGTH(COALESCE(first_name, '')) > 0 THEN ', ' ELSE '' END + || COALESCE(first_name, '') as name, + fk_contact_id, + null as company_name, + null as company_type, + null as company_id, + fk_salutation_id, + fk_ref_person_type_id, + title, + first_name, + last_name, + null as department +FROM tbl_external_person + ) g +ON g.fk_contact_id = c.ID; + + + +CREATE VIEW VW_DETAILED_CONTACT +AS +SELECT c.id, + c.uuid, + c.name, + c.contact_type, + c.fk_contact_id, + c.company_name, + c.company_type, + c.company_id, + c.anonymized, + s.uuid as salutation_uuid, + t.uuid as person_type_uuid, + c.title, + c.first_name, + c.last_name, + c.department, + c.note, + s.type as salutation_type, + t.type as person_type, + COALESCE(a.community, '') || + CASE WHEN LENGTH(COALESCE(a.street, '') || COALESCE(a.housenumber, '')) = 0 THEN '' ELSE ', ' END || + COALESCE(a.street, '') || + CASE WHEN LENGTH(COALESCE(a.housenumber, '')) = 0 THEN '' ELSE ' ' END || + COALESCE(a.housenumber, '') as main_address, + com.communication_data as email, + + UPPER( + COALESCE(c.name, '') || '|@|' + || COALESCE(company_name, '') || '|@|' + || COALESCE(c.company_type, '') || '|@|' + || COALESCE(c.title, '') || '|@|' + || COALESCE(c.first_name, '') || '|@|' + || COALESCE(c.last_name, '') || '|@|' + || COALESCE(c.department, '') || '|@|' + || COALESCE(c.note, '') || '|@|' + || COALESCE(s.type, '') || '|@|' + || COALESCE(t.type, '') || '|@|' + || COALESCE(a.street, '') || '|@|' + || COALESCE(a.housenumber, '') || '|@|' + || COALESCE(a.community, '') || '|@|' + || COALESCE(com.communication_data, '') + )as searchfield +FROM VW_GENERAL_CONTACT c +LEFT OUTER JOIN ref_salutation s ON c.fk_salutation_id = s.id +LEFT OUTER JOIN tbl_address a ON a.fk_contact_id = c.fk_contact_id and is_main_address = 1 +LEFT OUTER JOIN ref_person_type t ON c.fk_ref_person_type_id = t.id +LEFT OUTER JOIN tbl_communication com ON (com.fk_contact_id = c.fk_contact_id ) +LEFT OUTER JOIN ref_communication_type rct ON (rct.id = com.fk_communication_type) +WHERE COALESCE( rct.type_email, 1) = 1; + + + + +
diff --git a/pom.xml b/pom.xml index c4c715c..6b9eba3 100644 --- a/pom.xml +++ b/pom.xml
@@ -110,6 +110,21 @@ <scope>runtime</scope> </dependency> <dependency> + <groupId>com.oracle.database.jdbc</groupId> + <artifactId>ojdbc8</artifactId> + <version>19.6.0.0</version> + </dependency> + <dependency> + <groupId>com.oracle.database.jdbc</groupId> + <artifactId>ucp</artifactId> + <version>19.6.0.0</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>5.4.2.Final</version> + </dependency> + <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version>
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/config/OracleConfig.java b/src/main/java/org/eclipse/openk/contactbasedata/config/OracleConfig.java new file mode 100644 index 0000000..9e6a688 --- /dev/null +++ b/src/main/java/org/eclipse/openk/contactbasedata/config/OracleConfig.java
@@ -0,0 +1,60 @@ +package org.eclipse.openk.contactbasedata.config; + +import lombok.SneakyThrows; +import lombok.extern.log4j.Log4j2; +import oracle.ucp.jdbc.PoolDataSource; +import oracle.ucp.jdbc.PoolDataSourceFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import javax.sql.DataSource; +import java.sql.SQLException; + +@Log4j2 +@Configuration +@ConditionalOnProperty( + value="spring.datasource.enable-oracle-configuration", + havingValue = "true", + matchIfMissing = false) +public class OracleConfig { + @Value("${spring.datasource.url}") + private String url; + @Value("${spring.datasource.username}") + private String username; + @Value("${spring.datasource.password}") + private String password; + @Value("${oracle.ucp.minPoolSize}") + private String minPoolSize; + + @Value("${oracle.ucp.maxPoolSize}") + private String maxPoolSize; + + @Value("${spring.datasource.driver-class-name:oracle.jdbc.pool.OracleDataSource}") + private String driverClassName; + + @SneakyThrows + @Bean(name = "OracleUniversalConnectionPool") + @Primary + public DataSource getDataSource() { + PoolDataSource pds = null; + try { + pds = PoolDataSourceFactory.getPoolDataSource(); + + pds.setConnectionFactoryClassName(driverClassName); + pds.setURL(url); + pds.setUser(username); + pds.setPassword(password); + pds.setMinPoolSize(Integer.valueOf(minPoolSize)); + pds.setInitialPoolSize(10); + pds.setMaxPoolSize(Integer.valueOf(maxPoolSize)); + + } catch (SQLException ea) { + log.error("Error connecting to the database: " + ea.getMessage()); + } + + return pds; + } +} \ No newline at end of file
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/mapper/InternalPersonMapper.java b/src/main/java/org/eclipse/openk/contactbasedata/mapper/InternalPersonMapper.java index 8d57feb..46a3847 100644 --- a/src/main/java/org/eclipse/openk/contactbasedata/mapper/InternalPersonMapper.java +++ b/src/main/java/org/eclipse/openk/contactbasedata/mapper/InternalPersonMapper.java
@@ -33,7 +33,8 @@ @Mapping( source="refPersonType.uuid", target="personTypeUuid"), @Mapping( source="refPersonType.type", target="personType"), @Mapping( source="salutation.uuid", target="salutationUuid"), - @Mapping( source="salutation.type", target="salutationType") + @Mapping( source="salutation.type", target="salutationType"), + @Mapping( source="uidIdent", target="uid") }) InternalPersonDto toInternalPersonDto(TblInternalPerson tblInternalPerson); @@ -45,7 +46,8 @@ @Mapping( source="personTypeUuid", target="refPersonType.uuid"), @Mapping( source="personType", target="refPersonType.type"), @Mapping( source="salutationUuid", target="salutation.uuid"), - @Mapping( source="salutationType", target="salutation.type") + @Mapping( source="salutationType", target="salutation.type"), + @Mapping( source="uid", target="uidIdent") }) TblInternalPerson toTblInternalPerson(InternalPersonDto internalPersonDto); } \ No newline at end of file
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/model/TblAssignmentModulContact.java b/src/main/java/org/eclipse/openk/contactbasedata/model/TblAssignmentModulContact.java index 472dfdd..bd81f8e 100644 --- a/src/main/java/org/eclipse/openk/contactbasedata/model/TblAssignmentModulContact.java +++ b/src/main/java/org/eclipse/openk/contactbasedata/model/TblAssignmentModulContact.java
@@ -16,7 +16,14 @@ import lombok.Data; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.SequenceGenerator; import java.util.Date; import java.util.UUID; @@ -25,8 +32,8 @@ public class TblAssignmentModulContact { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "tbl_assignment_modul_contact_id_seq") - @SequenceGenerator(name = "tbl_assignment_modul_contact_id_seq", sequenceName = "tbl_assignment_modul_contact_id_seq", allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TBL_ASSIGN_MODUL_CNTCT_ID_SEQ") + @SequenceGenerator(name = "TBL_ASSIGN_MODUL_CNTCT_ID_SEQ", sequenceName = "TBL_ASSIGN_MODUL_CNTCT_ID_SEQ", allocationSize = 1) @Column(name = "id", updatable = false) private Long id; private UUID uuid;
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/model/TblInternalPerson.java b/src/main/java/org/eclipse/openk/contactbasedata/model/TblInternalPerson.java index 70727bb..7423ae2 100644 --- a/src/main/java/org/eclipse/openk/contactbasedata/model/TblInternalPerson.java +++ b/src/main/java/org/eclipse/openk/contactbasedata/model/TblInternalPerson.java
@@ -16,7 +16,15 @@ import lombok.Data; -import javax.persistence.*; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToOne; +import javax.persistence.SequenceGenerator; @Data @Entity @@ -31,7 +39,7 @@ private String lastName; private String title; private String department; - private String uid; + private String uidIdent; private String userRef;
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/repository/InternalPersonRepository.java b/src/main/java/org/eclipse/openk/contactbasedata/repository/InternalPersonRepository.java index b29aa5e..495604c 100644 --- a/src/main/java/org/eclipse/openk/contactbasedata/repository/InternalPersonRepository.java +++ b/src/main/java/org/eclipse/openk/contactbasedata/repository/InternalPersonRepository.java
@@ -30,7 +30,7 @@ Optional< TblInternalPerson > findByTblContactUuid(final UUID contactUuid); @Query( "select ip from TblInternalPerson ip where "+ - "(COALESCE(:uid) is null or COALESCE(:uid) is not null AND ip.uid=:uid) AND " + + "(COALESCE(:uid) is null or COALESCE(:uid) is not null AND ip.uidIdent=:uid) AND " + "(COALESCE(:userRef) is null or COALESCE(:userRef) is not null AND ip.userRef=:userRef)") Page<TblInternalPerson> findByFilter(@Param( "uid") String uid, @Param( "userRef") String userRef, @@ -38,7 +38,7 @@ Page<TblInternalPerson> findByContact_anonymizedFalseOrContact_anonymizedIsNull(Pageable pageable); // NOSONAR fd 07.02.2020: Method name cannot be changed - List<TblInternalPerson> findByUidNotNull(); + List<TblInternalPerson> findByUidIdentNotNull(); List<TblInternalPerson> findByUserRefNotNull(); }
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java b/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java index 6cf8c54..0bf4e5f 100644 --- a/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java +++ b/src/main/java/org/eclipse/openk/contactbasedata/service/InternalPersonService.java
@@ -107,7 +107,7 @@ existingInternalPerson.setFirstName(internalPersonDto.getFirstName()); existingInternalPerson.setTitle(internalPersonDto.getTitle()); existingInternalPerson.setDepartment(internalPersonDto.getDepartment()); - existingInternalPerson.setUid(internalPersonDto.getUid()); + existingInternalPerson.setUidIdent(internalPersonDto.getUid()); existingInternalPerson.setUserRef(internalPersonDto.getUserRef()); setFromInternalPersonDto( existingInternalPerson, internalPersonDto );
diff --git a/src/main/java/org/eclipse/openk/contactbasedata/service/LdapService.java b/src/main/java/org/eclipse/openk/contactbasedata/service/LdapService.java index 7aa035f..eb91580 100644 --- a/src/main/java/org/eclipse/openk/contactbasedata/service/LdapService.java +++ b/src/main/java/org/eclipse/openk/contactbasedata/service/LdapService.java
@@ -2,7 +2,6 @@ import lombok.extern.log4j.Log4j2; import org.apache.commons.lang.StringUtils; -import org.eclipse.openk.contactbasedata.exceptions.NotFoundException; import org.eclipse.openk.contactbasedata.model.RefCommunicationType; import org.eclipse.openk.contactbasedata.model.TblCommunication; import org.eclipse.openk.contactbasedata.model.TblInternalPerson; @@ -17,7 +16,12 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; import java.util.function.Function; import java.util.stream.Collectors; @@ -75,10 +79,10 @@ @Transactional public void synchronizeLDAP() { - List<TblInternalPerson> internalPersonList = internalPersonRepository.findByUidNotNull(); + List<TblInternalPerson> internalPersonList = internalPersonRepository.findByUidIdentNotNull(); Map<String, TblInternalPerson> uidToInternalPersonMap = internalPersonList.stream().collect( - Collectors.toMap(TblInternalPerson::getUid, Function.identity())); + Collectors.toMap(TblInternalPerson::getUidIdent, Function.identity())); List<LdapUser> allFoundLdapUsers = new ArrayList<>(); List<TblInternalPerson> allNotExistingLdapUsers = new ArrayList<>(); @@ -119,7 +123,7 @@ private void findExistingAndNotExistingLdapUsers(List<TblInternalPerson> internalPersonList, List<LdapUser> allFoundLdapUsers, List<TblInternalPerson> allNotExistingLdapUsers) { for (TblInternalPerson tblInternalPerson : internalPersonList) { - String uidTblInternalPerson = tblInternalPerson.getUid(); + String uidTblInternalPerson = tblInternalPerson.getUidIdent(); List<LdapUser> ldapUserByUIDResult = getLdapUserByUID(uidTblInternalPerson); if(ldapUserByUIDResult.isEmpty()){
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ed49424..d625af0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml
@@ -12,9 +12,21 @@ # ******************************************************************************* spring: datasource: - url: jdbc:postgresql://entopticadirx:5432/ContactBaseDataDevServer - username: cbd_service - password: cbd_service +## -> Postgres Configuration +# url: jdbc:postgresql://entopticadirx:5432/ContactBaseDataDevServer +# username: cbd_service +# password: cbd_service +## -> END: Postgres Configuration + +## -> Oracle Configuration + enable-oracle-configuration: true + url: jdbc:oracle:thin:@LIDLORADB2.PTA.DE:1521:NAPDB00 + username: dietricf + password: dietricf000 + jpa: + database-platform: org.hibernate.dialect.Oracle10gDialect + show-sql: false +## -> END: Oracle Configuration 1 flyway: enabled: false ldap: @@ -24,6 +36,13 @@ port: 10389 urls: ldap://entopkon:10389 +# oracle config -------------- +oracle: + ucp: + minPoolSize: 2 + maxPoolSize: 10 +# ----------------------------- + ldap-sync: attribute-mapping: uid: uid @@ -83,13 +102,16 @@ profiles: test datasource: + enable-oracle-configuration: false url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 -jpa: - hibernate: - ddl-auto: create - show-sql: true -flyway: - enabled: false + jpa: + database-platform: + hibernate: + # ddl-auto: create + show-sql: false + + flyway: + enabled: false ldap-sync: scheduling: @@ -194,6 +216,7 @@ spring: profiles: qserver datasource: + enable-oracle-configuration: false url: jdbc:postgresql://localhost:5432/contactBaseDataQa username: cbd_service password: cbd_service
diff --git a/src/main/resources/db/migration/V0_23__CREATE_CBD_DB.sql b/src/main/resources/db/migration/V0_23__CREATE_CBD_DB.sql new file mode 100644 index 0000000..2b5d3f9 --- /dev/null +++ b/src/main/resources/db/migration/V0_23__CREATE_CBD_DB.sql
@@ -0,0 +1,711 @@ +----------------------------------------------------------------------------------- +-- ******************************************************************************* +-- * Copyright (c) 2019 Contributors to the Eclipse Foundation +-- * +-- * See the NOTICE file(s) distributed with this work for additional +-- * information regarding copyright ownership. +-- * +-- * This program and the accompanying materials are made available under the +-- * terms of the Eclipse Public License v. 2.0 which is available at +-- * http://www.eclipse.org/legal/epl-2.0. +-- * +-- * SPDX-License-Identifier: EPL-2.0 +-- ******************************************************************************* +----------------------------------------------------------------------------------- + +-- CREATE ROLE CBD_SERVICE LOGIN +-- NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION; +-- ALTER ROLE CBD_SERVICE with password 'cbd_service'; +-- Insert new Columns into table REF_COMMUNICATION_TYPE ('EDITABLE, 'MAPPING_LDAP') + +-- --------------------------------------------- +-- DROPS +-- --------------------------------------------- +DROP TABLE IF EXISTS public.VERSION CASCADE; + +DROP TABLE IF EXISTS public.TBL_ADDRESS CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_ADDRESS_ID_SEQ; + +DROP TABLE IF EXISTS public.TBL_COMMUNICATION CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_COMMUNICATION_ID_SEQ; + +DROP TABLE IF EXISTS public.TBL_CONTACT_PERSON CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_CONTACT_PERSON_ID_SEQ; + +DROP TABLE IF EXISTS public.TBL_COMPANY CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_COMPANY_ID_SEQ; + +DROP TABLE IF EXISTS public.TBL_EXTERNAL_PERSON CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_EXTERNAL_PERSON_ID_SEQ; + +DROP TABLE IF EXISTS public.TBL_INTERNAL_PERSON CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_INTERNAL_PERSON_ID_SEQ; + +DROP TABLE IF EXISTS public.TBL_CONTACT CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_CONTACT_ID_SEQ; + +DROP TABLE IF EXISTS public.REF_ADDRESS_TYPE CASCADE; +DROP SEQUENCE IF EXISTS public.REF_ADDRESS_TYPE_ID_SEQ; + +DROP TABLE IF EXISTS public.REF_PERSON_TYPE CASCADE; +DROP SEQUENCE IF EXISTS public.REF_PERSON_TYPE_ID_SEQ; + +DROP TABLE IF EXISTS public.REF_COMMUNICATION_TYPE CASCADE; +DROP SEQUENCE IF EXISTS public.REF_COMMUNICATION_TYPE_ID_SEQ; + +DROP TABLE IF EXISTS public.REF_SALUTATION CASCADE; +DROP SEQUENCE IF EXISTS public.REF_SALUTATION_ID_SEQ; + +DROP TABLE IF EXISTS public.TBL_ASSIGNMENT_MODUL_CONTACT CASCADE; +DROP SEQUENCE IF EXISTS public.TBL_ASSIGNMENT_MODUL_CONTACT_ID_SEQ; + +-- --------------------------------------------- +-- TABLE VERSION +-- --------------------------------------------- +CREATE TABLE public.VERSION +( + ID integer NOT NULL, + VERSION character varying(50) NOT NULL, + CONSTRAINT REF_VERSION_PKEY PRIMARY KEY (id) +); + +ALTER TABLE public.VERSION + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.VERSION TO CBD_SERVICE; + +INSERT INTO public.VERSION (ID, VERSION) VALUES ( 1, '00-DEV' ); + + +-- --------------------------------------------- +-- TABLE TBL_CONTACT +-- --------------------------------------------- +CREATE SEQUENCE public.tbl_contact_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.tbl_contact_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.TBL_CONTACT +( + ID bigint NOT NULL DEFAULT nextval('tbl_contact_id_seq'::regclass), + UUID uuid NOT NULL, + CONTACT_TYPE character varying(3), + NOTE character varying(255), + ANONYMIZED boolean, + CONSTRAINT TBL_CONTACT_PKEY PRIMARY KEY (ID) +); + + + +ALTER TABLE public.TBL_CONTACT + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.TBL_CONTACT TO CBD_SERVICE; + +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ae3f2ec1-ccc5-4269-a48f-dd40e37fa14e', '4CO', 'company 1 (id=1)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'fc7f598b-0d51-46bb-9563-99851fe6a3ad', '4CO', 'company 2 (id=2)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '556b91be-6d57-432f-93ed-65604dd6e5cd', '1CP', 'contact person 1 (id=3)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '116380e3-25c5-4179-b40a-8abebe10fe07', '1CP', 'contact person 2 (id=4)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '7782179b-fb79-4370-8f71-f4c71470d006', '3IP', 'internal person 1 (id=5)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '8963aa38-d021-4dc9-bd70-d3734ccd20c4', '3IP', 'internal person 2 (id=6)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'c862d604-5766-43d6-a7e8-a4bac2bd01e1', '2EP', 'external person 1 (id=7)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'fa3d981b-a7d6-4965-a623-cdbc69404153', '2EP', 'external person 2 (id=8)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ceba21e9-e685-483b-840e-ad167860a696', '4CO', 'anonymous company A (id=9)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '7889c814-9752-4e4e-a9fe-b46f36a38ccd', '4CO', 'anonymous company B (id=10)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '618a01a3-f348-44cc-9ddd-c9df946b0212', '1CP', 'anoymous contact person A1 (id=11)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '4ed82474-3878-457a-baef-c28b8e486f25', '1CP', 'anoymous contact persion A2 (id=12)', true ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( '8fe41b90-d10c-4a70-8fde-0990286ad3c6', '3IP', 'internal person 3 (id=13)', null ); +INSERT INTO public.TBL_CONTACT (UUID, CONTACT_TYPE, NOTE, ANONYMIZED) VALUES ( 'ab804610-d6a4-4803-a4a1-3f6cb742b2a4', '3IP', 'internal person 4 (id=14)', null ); + + +CREATE UNIQUE INDEX idx_tbl_contact_contact_type ON public.TBL_CONTACT ( ID ASC ); +CREATE UNIQUE INDEX idx_cntct_uuid ON public.TBL_CONTACT (UUID); +CREATE INDEX idx_cntct_anonym ON public.TBL_CONTACT (ANONYMIZED); + + +-- --------------------------------------------- +-- TABLE REF_ADDRESS_TYPE +-- --------------------------------------------- +CREATE SEQUENCE public.ref_address_type_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.ref_address_type_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.REF_ADDRESS_TYPE +( + ID bigint NOT NULL DEFAULT nextval('ref_address_type_id_seq'::regclass), + UUID uuid NOT NULL, + TYPE character varying(30), + DESCRIPTION character varying(255), + CONSTRAINT REF_ADDRESS_TYPE_PKEY PRIMARY KEY (ID) +); + +ALTER TABLE public.REF_ADDRESS_TYPE + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.REF_ADDRESS_TYPE TO CBD_SERVICE; + +CREATE UNIQUE INDEX idx_ref_address_type_uuid ON public.REF_ADDRESS_TYPE ( UUID ASC ); + +INSERT INTO public.REF_ADDRESS_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( '3802e681-9396-434e-b19c-5fedcec40ba7', 'Geschäftsadresse', 'Adresse des Hauptfirmensitzes' ); +INSERT INTO public.REF_ADDRESS_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( 'f43ed6ac-9e7a-40f6-acc9-ec6b73eebf79', 'Privatadresse', 'private Anschrift' ); +INSERT INTO public.REF_ADDRESS_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( '70fd0811-f674-4f3a-96a7-7ae29fc95188', 'Lieferadresse', 'Adresse für Lieferungen' ); + + +-- --------------------------------------------- +-- TABLE REF_PERSON_TYPE +-- --------------------------------------------- +CREATE SEQUENCE public.ref_person_type_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.ref_person_type_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.REF_PERSON_TYPE +( + ID bigint NOT NULL DEFAULT nextval('ref_person_type_id_seq'::regclass), + UUID uuid NOT NULL, + TYPE character varying(30), + DESCRIPTION character varying(255), + CONSTRAINT REF_PERSON_TYPE_PKEY PRIMARY KEY (ID) +); +ALTER TABLE public.REF_PERSON_TYPE + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.REF_PERSON_TYPE TO CBD_SERVICE; + +CREATE UNIQUE INDEX idx_ref_person_type_uuid ON public.REF_PERSON_TYPE ( UUID ASC ); + +INSERT INTO public.REF_PERSON_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( '47ce68b7-6d44-453e-b421-19020fd791b5', 'Rechtsanwalt', '' ); +INSERT INTO public.REF_PERSON_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( 'a7522c72-14d0-4e9d-afe3-bfcb3ffbec10', 'Geschäftsführer', '' ); +INSERT INTO public.REF_PERSON_TYPE (UUID, TYPE, DESCRIPTION) VALUES ( '2eb4885e-7363-4918-90ed-b7d5d84cfd3f', 'Rechnungsempfänger', 'Person, der Rechnungen zukommen' ); + + +-- --------------------------------------------- +-- TABLE REF_COMMUNICATION_TYPE +-- --------------------------------------------- +CREATE SEQUENCE public.ref_communication_type_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.ref_communication_type_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.REF_COMMUNICATION_TYPE +( + ID bigint NOT NULL DEFAULT nextval('ref_communication_type_id_seq'::regclass), + UUID uuid NOT NULL, + TYPE character varying(30), + DESCRIPTION character varying(255), + TYPE_EMAIL boolean, + CONSTRAINT REF_COMMUNICATION_TYPE_PKEY PRIMARY KEY (ID) +); +ALTER TABLE public.REF_COMMUNICATION_TYPE + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.REF_COMMUNICATION_TYPE TO CBD_SERVICE; + +CREATE UNIQUE INDEX idx_ref_communication_type_uuid ON public.REF_COMMUNICATION_TYPE ( UUID ASC ); + +INSERT INTO public.REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( '4757ca3a-72c2-4f13-a2f6-ce092e3eadf4', 'E-Mail', 'E-Mail Adresse', true ); +INSERT INTO public.REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( '77028572-ff57-4c1d-999a-78fa3fcbc1cd', 'Festnetz', '', false ); +INSERT INTO public.REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( 'f7d5b343-00c2-4d7f-8e03-009aad3d90f7', 'Mobil', '', false ); +INSERT INTO public.REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( '2bfe40f9-c4eb-4d2e-855f-6b0883912846', 'Fax', '', false ); +INSERT INTO public.REF_COMMUNICATION_TYPE (UUID, TYPE, DESCRIPTION, TYPE_EMAIL) VALUES ( 'd00d1a61-c8e7-43b2-959f-66e986731441', 'WhatsApp', '', false ); + +-- --------------------------------------------- +-- TABLE REF_SALUTATION +-- --------------------------------------------- +CREATE SEQUENCE public.ref_salutation_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.ref_salutation_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.REF_SALUTATION +( + ID bigint NOT NULL DEFAULT nextval('ref_salutation_id_seq'::regclass), + UUID uuid NOT NULL, + TYPE character varying(30), + DESCRIPTION character varying(255), + CONSTRAINT REF_SALUTATION_PKEY PRIMARY KEY (ID) +); +ALTER TABLE public.REF_SALUTATION + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.REF_SALUTATION TO CBD_SERVICE; + +CREATE UNIQUE INDEX idx_ref_salutation_uuid ON public.REF_SALUTATION ( UUID ASC ); + +INSERT INTO public.REF_SALUTATION (UUID, TYPE, DESCRIPTION) VALUES ( '90119f18-5562-425d-9a36-3dd58ea125e5', 'Herr', 'Anrede männlich' ); +INSERT INTO public.REF_SALUTATION (UUID, TYPE, DESCRIPTION) VALUES ( '4e873baa-e4f5-4585-8b16-2db8fac66538', 'Frau', 'Anrede weiblich' ); + + +-- --------------------------------------------- +-- TABLE TBL_ADDRESS +-- --------------------------------------------- +CREATE SEQUENCE public.tbl_address_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.tbl_address_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.TBL_ADDRESS +( + ID bigint NOT NULL DEFAULT nextval('tbl_address_id_seq'::regclass), + UUID uuid NOT NULL, + FK_CONTACT_ID bigint NOT NULL, + FK_ADDRESS_TYPE bigint, + IS_MAIN_ADDRESS boolean, + POSTCODE character varying(30), + COMMUNITY character varying(255), + COMMUNITY_SUFFIX character varying(255), + STREET character varying(255), + HOUSENUMBER character varying(30), + WGS_84_ZONE character varying(255), + LATITUDE character varying(255), + LONGITUDE character varying(255), + URL_MAP character varying(255), + NOTE character varying(255), + + CONSTRAINT TBL_ADDRESS_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_ADDRESS__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES public.TBL_CONTACT(ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_ADDRESS__ADDRESS_TYPE_ID_FKEY FOREIGN KEY (FK_ADDRESS_TYPE) + REFERENCES public.REF_ADDRESS_TYPE (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); +ALTER TABLE public.TBL_ADDRESS + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.TBL_ADDRESS TO CBD_SERVICE; + +CREATE UNIQUE INDEX idx_tbl_address_uuid ON public.TBL_ADDRESS ( UUID ASC ); + +INSERT INTO public.TBL_ADDRESS (UUID, FK_CONTACT_ID, FK_ADDRESS_TYPE, IS_MAIN_ADDRESS, POSTCODE, COMMUNITY, COMMUNITY_SUFFIX, STREET, HOUSENUMBER, WGS_84_ZONE, LATITUDE, LONGITUDE, URL_MAP, NOTE) VALUES ( '37e800fe-64f0-4834-8b83-8453cbb936a5', 2, 1, true, '12345', 'Heringsdorf','', 'Flunderweg', '5', '', '53 NL', '3 WB','www.xyz', 'nur über Seeweg erreichbar'); +INSERT INTO public.TBL_ADDRESS (UUID, FK_CONTACT_ID, FK_ADDRESS_TYPE, IS_MAIN_ADDRESS, POSTCODE, COMMUNITY, COMMUNITY_SUFFIX, STREET, HOUSENUMBER, WGS_84_ZONE, LATITUDE, LONGITUDE, URL_MAP, NOTE) VALUES ( '8a1202ae-2532-474e-8367-a1f0e13e9fbd', 1, 2, false, '67890', 'Stralsund','', 'Schollendamm', '18', '', '53 N', '2 WB','www.xyz', 'Hochwassergefahr'); + + +-- --------------------------------------------- +-- TABLE TBL_COMMUNICATION +-- --------------------------------------------- +CREATE SEQUENCE public.tbl_communication_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.tbl_communication_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.TBL_COMMUNICATION +( + ID bigint NOT NULL DEFAULT nextval('tbl_communication_id_seq'::regclass), + UUID uuid NOT NULL, + FK_CONTACT_ID bigint NOT NULL, + FK_COMMUNICATION_TYPE bigint, + COMMUNICATION_DATA character varying(1024), + NOTE character varying(255), + + CONSTRAINT TBL_COMMUNICATION_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_COMMUNICATION__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES public.TBL_CONTACT(ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_COMMUNICATION__COMMUNICATION_TYPE_ID_FKEY FOREIGN KEY (FK_COMMUNICATION_TYPE) + REFERENCES public.REF_COMMUNICATION_TYPE (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); +ALTER TABLE public.TBL_COMMUNICATION + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.TBL_COMMUNICATION TO CBD_SERVICE; + +CREATE UNIQUE INDEX idx_tbl_communication_uuid ON public.TBL_COMMUNICATION ( UUID ASC ); + +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( '25f6d7cc-b168-4dd5-a36d-6f14b2f956e9', 2, 2, 'bitte melden Sie sich bei uns', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( 'a5fa380e-8f33-4ea7-9416-e03d11b91cae', 1, 3, 'bitte melden zwecks Terminabstimmung', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( 'c0dcef80-ca07-48b7-a3ed-2c99c4388928', 1, 1, 'info@bigbang.com', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( 'd19d9e10-d2dd-4383-84ec-2fe96421c0a3', 2, 1, 'info@pharmapeekltd.com', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( '234b63e4-d8db-48ab-899f-0320903c01af', 3, 1, 'reinbold.tab@pharmapeek.com', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( '11e25c02-de00-430d-b6cd-f02f7c60e026', 5, 1, 'PaulineF@gmx.net', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( '9ca29c3b-e189-4ce9-9401-15001c769627', 6, 1, 'mo@gmail.com', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( '05505b1a-61df-45c0-b006-64165cbadfa2', 7, 1, 'MGruebelSport@fogger.mil', 'Info...'); +INSERT INTO public.TBL_COMMUNICATION (UUID, FK_CONTACT_ID, FK_COMMUNICATION_TYPE, COMMUNICATION_DATA, NOTE) VALUES ( 'b52dabaf-d156-4fd0-a07c-510673112a15', 8, 1, 'Mini.osterbrink@yahoo.ie', 'Info...'); + +-- --------------------------------------------- +-- TABLE TBL_COMPANY +-- --------------------------------------------- +CREATE SEQUENCE public.tbl_company_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.tbl_company_id_seq + OWNER TO CBD_SERVICE; + + +CREATE TABLE public.TBL_COMPANY +( + ID bigint NOT NULL DEFAULT nextval('tbl_company_id_seq'::regclass), + COMPANY_NAME character varying(255), + COMPANY_TYPE character varying(30), + HR_NUMBER character varying(255), + FK_CONTACT_ID bigint NOT NULL, + CONSTRAINT TBL_COMPANY_PKEY PRIMARY KEY (id), + CONSTRAINT TBL_COMPANY__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES public.TBL_CONTACT(ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); +ALTER TABLE public.TBL_COMPANY + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.TBL_COMPANY TO CBD_SERVICE; + +INSERT INTO public.TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( 'BigBang Logistic', 'Logistik', '123', 1 ); +INSERT INTO public.TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( 'Pharma Peek', 'Pharma', '345', 2 ); +INSERT INTO public.TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( '***', '***', null, 9 ); +INSERT INTO public.TBL_COMPANY (COMPANY_NAME, COMPANY_TYPE, HR_NUMBER, FK_CONTACT_ID) VALUES ( '***', '***', null, 10 ); + + +-- --------------------------------------------- +-- TABLE TBL_CONTACT_PERSON +-- --------------------------------------------- +CREATE SEQUENCE public.tbl_contact_person_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.tbl_contact_person_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.TBL_CONTACT_PERSON +( + ID bigint NOT NULL DEFAULT nextval('tbl_contact_person_id_seq'::regclass), + FIRST_NAME character varying(255), + LAST_NAME character varying(255), + TITLE character varying(255), + FK_SALUTATION_ID bigint, + FK_REF_PERSON_TYPE_ID bigint NULL, + FK_CONTACT_ID bigint NOT NULL, + FK_COMPANY_ID bigint NOT NULL, + CONSTRAINT TBL_CONTACT_PERSON_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_CONTACT_PERSON__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES public.TBL_CONTACT (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_CONTACT_PERSON__PERSON_TYPE_ID_FKEY FOREIGN KEY (FK_REF_PERSON_TYPE_ID) + REFERENCES public.REF_PERSON_TYPE (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_CONTACT_PERSON__SALUTATION_ID_FKEY FOREIGN KEY (FK_SALUTATION_ID) + REFERENCES public.REF_SALUTATION (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_CONTACT_PERSON__COMPANY_ID_FKEY FOREIGN KEY (FK_COMPANY_ID) + REFERENCES public.TBL_COMPANY (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); +ALTER TABLE public.TBL_CONTACT_PERSON + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.TBL_CONTACT_PERSON TO CBD_SERVICE; + +INSERT INTO public.TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( 'Tabea', 'Reinebold', 'Dr.', 2, 1, 3, 2); +INSERT INTO public.TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( 'Jan', 'Wacker', '', 1, 1, 4, 2); +INSERT INTO public.TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( '***', '***', null, null, null, 11, 3); +INSERT INTO public.TBL_CONTACT_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID, FK_COMPANY_ID) VALUES ( '***', '***', null, null, null, 12, 2); + +-- --------------------------------------------- +-- TABLE TBL_EXTERNAL_PERSON +-- --------------------------------------------- +CREATE SEQUENCE public.tbl_external_person_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.tbl_external_person_id_seq + OWNER TO CBD_SERVICE; + +CREATE TABLE public.TBL_EXTERNAL_PERSON +( + ID bigint NOT NULL DEFAULT nextval('tbl_external_person_id_seq'::regclass), + FIRST_NAME character varying(255), + LAST_NAME character varying(255), + TITLE character varying(255), + FK_SALUTATION_ID bigint, + FK_REF_PERSON_TYPE_ID bigint, + FK_CONTACT_ID bigint NOT NULL, + CONSTRAINT TBL_EXTERNAL_PERSON_PKEY PRIMARY KEY (id), + CONSTRAINT TBL_EXTERNAL_PERSON__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES public.TBL_CONTACT (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_EXTERNAL_PERSON__SALUTATION_ID_FKEY FOREIGN KEY (FK_SALUTATION_ID) + REFERENCES public.REF_SALUTATION (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_EXTERNAL_PERSON__PERSON_TYPE_ID_FKEY FOREIGN KEY (FK_REF_PERSON_TYPE_ID) + REFERENCES public.REF_PERSON_TYPE (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); +ALTER TABLE public.TBL_EXTERNAL_PERSON + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.TBL_EXTERNAL_PERSON TO CBD_SERVICE; + +INSERT INTO public.TBL_EXTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID) VALUES ( 'Monica', 'Grübel', 'Dipl.-Sportlehrerin', 2, 1, 7); +INSERT INTO public.TBL_EXTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, FK_CONTACT_ID) VALUES ( 'Maurice', 'Fürstenberg', 'B.A.', 2, 2, 8); + + +-- --------------------------------------------- +-- TABLE TBL_INTERNAL_PERSON +-- --------------------------------------------- +CREATE SEQUENCE public.tbl_internal_person_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.tbl_internal_person_id_seq + OWNER TO CBD_SERVICE; +CREATE TABLE public.TBL_INTERNAL_PERSON +( + ID bigint NOT NULL DEFAULT nextval('tbl_internal_person_id_seq'::regclass), + FIRST_NAME character varying(255), + LAST_NAME character varying(255), + TITLE character varying(255), + FK_SALUTATION_ID bigint, + FK_REF_PERSON_TYPE_ID bigint, + DEPARTMENT character varying(255), + UID_IDENT character varying(255), + USER_REF character varying(255), + FK_CONTACT_ID bigint NOT NULL, + CONSTRAINT TBL_INTERNAL_PERSON_PKEY PRIMARY KEY (ID), + CONSTRAINT TBL_INTERNAL_PERSON__CONTACT_ID_FKEY FOREIGN KEY (FK_CONTACT_ID) + REFERENCES public.TBL_CONTACT (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_INTERNAL_PERSON__SALUTATION_ID_FKEY FOREIGN KEY (FK_SALUTATION_ID) + REFERENCES public.REF_SALUTATION (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT TBL_INTERNAL_PERSON__PERSON_TYPE_ID_FKEY FOREIGN KEY (FK_REF_PERSON_TYPE_ID) + REFERENCES public.REF_PERSON_TYPE (ID) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); +ALTER TABLE public.TBL_INTERNAL_PERSON + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.TBL_INTERNAL_PERSON TO CBD_SERVICE; + +CREATE UNIQUE INDEX idx_tbl_internal_person_uid ON public.TBL_INTERNAL_PERSON ( UID_IDENT ASC ); +CREATE UNIQUE INDEX idx_tbl_internal_person_user_ref ON public.TBL_INTERNAL_PERSON ( USER_REF ASC ); + +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Pauline', 'Freudenberg', 'B.Sc.', 1, 1,'Abteilung Rechnungsstellung', '66cd78c3-6716-4ab3-b834-a199fc796b88', 'PFREUD', 5); +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Bernhardt', 'Iffland', '', 2, 2,'Kreativ', '4124e4e7-3488-4492-bf39-75e6a23a1c1a', 'BIFFL', 6); +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Horatio', 'Hornblower', 'Capt.', 1, 2,'Royal Navy', 'hhornblo', 'HORNB', 13); +INSERT INTO public.TBL_INTERNAL_PERSON (FIRST_NAME, LAST_NAME, TITLE, FK_SALUTATION_ID, FK_REF_PERSON_TYPE_ID, DEPARTMENT, UID_IDENT, USER_REF, FK_CONTACT_ID) VALUES ( 'Cornelius', 'Buckley', '', 1, 2,'Royal Navy', null, 'BUCKC', 14); +-- --------------------------------------------- +-- TABLE TBL_ASSIGNMENT_MODUL_CONTACT +-- --------------------------------------------- +CREATE SEQUENCE public.TBL_ASSIGN_MODUL_CNTCT_ID_SEQ + INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1; +ALTER TABLE public.TBL_ASSIGN_MODUL_CNTCT_ID_SEQ + OWNER TO CBD_SERVICE; + +CREATE TABLE public.TBL_ASSIGNMENT_MODUL_CONTACT +( + id bigint NOT NULL DEFAULT nextval('TBL_ASSIGN_MODUL_CNTCT_ID_SEQ'::regclass), + uuid uuid NOT NULL, + fk_contact_id bigint NOT NULL, + modul_name character varying(255), + assignment_date timestamp, + expiring_date timestamp, + deletion_lock_until timestamp, + assignment_note character varying(2048), + CONSTRAINT tbl_assignment_modul_contact_pkey PRIMARY KEY (id), + CONSTRAINT tbl_assignment_modul_contact_id_fkey FOREIGN KEY (fk_contact_id) + REFERENCES public.tbl_contact (id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +) +WITH ( + OIDS=FALSE +); +ALTER TABLE public.tbl_assignment_modul_contact + OWNER TO cbd_service; +GRANT ALL ON TABLE public.tbl_assignment_modul_contact TO cbd_service; + +INSERT INTO public.tbl_assignment_modul_contact(uuid, fk_contact_id, modul_name, assignment_date, expiring_date, deletion_lock_until, assignment_note) VALUES ( 'dfc2979c-40e3-11ea-b77f-2e728ce88125', 1, 'Betriebstagebuch', '2020-01-19 10:23:54', '2021-01-19 00:00:00', '2021-01-19 00:00:00', 'seit Januar zugeordnet'); +INSERT INTO public.tbl_assignment_modul_contact(uuid, fk_contact_id, modul_name, assignment_date, expiring_date, deletion_lock_until, assignment_note) VALUES ( '4009bce2-40e5-11ea-b77f-2e728ce88125', 1, 'Störinfos', '2020-02-27 10:23:54', '2019-02-27 00:00:00', '2019-02-27 00:00:00', 'seit Februar zugeordnet'); + +-- ------------------------------------- +-- VIEWS ------------------------------- +-- ------------------------------------- +DROP VIEW IF EXISTS VW_GENERAL_CONTACT CASCADE; + +CREATE VIEW VW_GENERAL_CONTACT +AS +SELECT g.id, + c.uuid, + g.name, + c.contact_type, + g.fk_contact_id, + g.company_name, + g.company_type, + g.company_id, + g.fk_salutation_id, + g.fk_ref_person_type_id, + g.title, + g.first_name, + g.last_name, + g.department, + c.note, + c.anonymized +FROM tbl_contact c +INNER JOIN ( + +SELECT company.id, + company_name as name, + fk_contact_id, + company_name, + company_type, + cntct.uuid as company_id, + null as fk_salutation_id, + null as fk_ref_person_type_id, + null as title, + null as first_name, + null as last_name, + null as department +FROM tbl_company company +INNER JOIN tbl_contact cntct ON company.fk_contact_id = cntct.id + +UNION + +SELECT p.id, + COALESCE(p.last_name, '') + || CASE WHEN COALESCE(p.last_name, '') <> '' AND COALESCE(p.first_name) <> '' THEN ', ' ELSE '' END + || COALESCE(p.first_name,'') || ' [' || COALESCE(c.company_name, '') || ']' as name, + p.fk_contact_id, + c.company_name, + c.company_type, + company_contact.uuid as company_id, + p.fk_salutation_id, + p.fk_ref_person_type_id, + p.title, + p.first_name, + p.last_name, + null as department +FROM tbl_contact_person p +INNER JOIN tbl_company c ON c.id = p.fk_company_id +INNER JOIN tbl_contact company_contact ON c.fk_contact_id = company_contact.id + +UNION + +SELECT id, + COALESCE(last_name, '') + || CASE WHEN COALESCE(last_name, '') <> '' AND COALESCE(first_name) <> '' THEN ', ' ELSE '' END + || COALESCE(first_name, '') as name, + fk_contact_id, + null as company_name, + null as company_type, + null as company_id, + fk_salutation_id, + fk_ref_person_type_id, + title, + first_name, + last_name, + department +FROM tbl_internal_person + +UNION + +SELECT id, + COALESCE(last_name, '') + || CASE WHEN COALESCE(last_name, '') <> '' AND COALESCE(first_name) <> '' THEN ', ' ELSE '' END + || COALESCE(first_name, '') as name, + fk_contact_id, + null as company_name, + null as company_type, + null as company_id, + fk_salutation_id, + fk_ref_person_type_id, + title, + first_name, + last_name, + null as department +FROM tbl_external_person + ) g +ON g.fk_contact_id = c.ID; + +ALTER VIEW public.VW_GENERAL_CONTACT + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.VW_GENERAL_CONTACT TO CBD_SERVICE; + + +DROP VIEW IF EXISTS VW_DETAILED_CONTACT; + +CREATE VIEW VW_DETAILED_CONTACT +AS +SELECT c.id, + c.uuid, + c.name, + c.contact_type, + c.fk_contact_id, + c.company_name, + c.company_type, + c.company_id, + c.anonymized, + s.uuid as salutation_uuid, + t.uuid as person_type_uuid, + c.title, + c.first_name, + c.last_name, + c.department, + c.note, + s.type as salutation_type, + t.type as person_type, + COALESCE(a.community, '') || + CASE WHEN COALESCE(a.street, '') || COALESCE(a.housenumber, '') = '' THEN '' ELSE ', ' END || + COALESCE(a.street, '') || + CASE WHEN COALESCE(a.housenumber, '') = '' THEN '' ELSE ' ' END || + COALESCE(a.housenumber, '') as main_address, + com.communication_data as email, + + UPPER( + COALESCE(c.name, '') || '|@|' + || COALESCE(company_name, '') || '|@|' + || COALESCE(c.company_type, '') || '|@|' + || COALESCE(c.title, '') || '|@|' + || COALESCE(c.first_name, '') || '|@|' + || COALESCE(c.last_name, '') || '|@|' + || COALESCE(c.department, '') || '|@|' + || COALESCE(c.note, '') || '|@|' + || COALESCE(s.type, '') || '|@|' + || COALESCE(t.type, '') || '|@|' + || COALESCE(a.street, '') || '|@|' + || COALESCE(a.housenumber, '') || '|@|' + || COALESCE(a.community, '') || '|@|' + || COALESCE(com.communication_data, '') + )as searchfield +FROM VW_GENERAL_CONTACT c +LEFT OUTER JOIN ref_salutation s ON c.fk_salutation_id = s.id +LEFT OUTER JOIN tbl_address a ON a.fk_contact_id = c.fk_contact_id and is_main_address = true +LEFT OUTER JOIN ref_person_type t ON c.fk_ref_person_type_id = t.id +LEFT OUTER JOIN tbl_communication com ON (com.fk_contact_id = c.fk_contact_id AND com.fk_communication_type = + (SELECT ct.id FROM ref_communication_type ct WHERE ct.type_email = true)) ; + +ALTER VIEW public.VW_DETAILED_CONTACT + OWNER TO CBD_SERVICE; +GRANT ALL ON TABLE public.VW_DETAILED_CONTACT TO CBD_SERVICE; + + + +
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressControllerTest.java index 93936f8..03f8a35 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressControllerTest.java
@@ -34,13 +34,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class AddressControllerTest { +@ActiveProfiles("test") +class AddressControllerTest { @MockBean private AddressService addressService; @@ -49,7 +54,7 @@ private MockMvc mockMvc; @Test - public void shouldReturnAddressesForAContact() throws Exception { + void shouldReturnAddressesForAContact() throws Exception { List<AddressDto> listDtos = MockDataHelper.mockAddressDtoList(); when(addressService.getAddressesByContactUuid(any(UUID.class))).thenReturn(listDtos); @@ -60,7 +65,7 @@ } @Test - public void shouldReturnSingleAddress() throws Exception { + void shouldReturnSingleAddress() throws Exception { AddressDto addressDto = MockDataHelper.mockAddressDto(); when(addressService.getAddress(any(UUID.class), any(UUID.class))).thenReturn(addressDto); @@ -72,7 +77,7 @@ @Test - public void shouldInsertAddress() throws Exception { + void shouldInsertAddress() throws Exception { AddressDto addressDto = MockDataHelper.mockAddressDto(); addressDto.setUuid(UUID.fromString("1ad98d00-3774-11ea-850d-2e728ce88125")); addressDto.setCommunity("Mullewapp"); @@ -118,7 +123,7 @@ @Test - public void shouldUpdateAddress() throws Exception { + void shouldUpdateAddress() throws Exception { AddressDto addressDto = MockDataHelper.mockAddressDto(); when( addressService.updateAddress(any(UUID.class), any(AddressDto.class))).thenReturn(addressDto); @@ -130,7 +135,7 @@ } @Test - public void shouldNotUpdateAddressDueToInvalidArgs() throws Exception { + void shouldNotUpdateAddressDueToInvalidArgs() throws Exception { AddressDto addressDto = MockDataHelper.mockAddressDto(); addressDto.setAddressTypeUuid(null); @@ -143,7 +148,7 @@ } @Test - public void shouldNotUpdateAddress() throws Exception { + void shouldNotUpdateAddress() throws Exception { AddressDto addressDto = MockDataHelper.mockAddressDto(); when( addressService.updateAddress(any(UUID.class), any(AddressDto.class))).thenReturn(addressDto); @@ -155,7 +160,7 @@ } @Test - public void shouldDeleteAddress() throws Exception { + void shouldDeleteAddress() throws Exception { mockMvc.perform(delete("/contacts/{contactUuid}/addresses/{addressUuid}", UUID.randomUUID(), UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful());
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressTypeControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressTypeControllerTest.java index 7c629aa..9a46c1f 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressTypeControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/AddressTypeControllerTest.java
@@ -34,13 +34,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class AddressTypeControllerTest { +@ActiveProfiles("test") +class AddressTypeControllerTest { @MockBean private AddressTypeService addressTypeService; @@ -49,7 +54,7 @@ private MockMvc mockMvc; @Test - public void shouldReturnAllAddressTypes() throws Exception { + void shouldReturnAllAddressTypes() throws Exception { List<AddressTypeDto> sds = MockDataHelper.mockAddressTypesDtos(); when(addressTypeService.findAllAddressTypes()).thenReturn(sds); @@ -60,7 +65,7 @@ } @Test - public void shouldReturnSingleAddressType() throws Exception { + void shouldReturnSingleAddressType() throws Exception { AddressTypeDto addressTypeDto = MockDataHelper.mockAddressTypeDto(); when(addressTypeService.getAddressTypeByUuid(any(UUID.class))).thenReturn(addressTypeDto); @@ -71,7 +76,7 @@ } @Test - public void shouldInsertAddressType() throws Exception { + void shouldInsertAddressType() throws Exception { AddressTypeDto addressTypeDto = MockDataHelper.mockAddressTypeDto(); addressTypeDto.setType("Master"); addressTypeDto.setDescription("of the universe"); @@ -87,7 +92,7 @@ } @Test - public void shouldUpdateAddressType() throws Exception { + void shouldUpdateAddressType() throws Exception { AddressTypeDto addressTypeDto = MockDataHelper.mockAddressTypeDto(); addressTypeDto.setUuid(UUID.randomUUID()); @@ -100,7 +105,7 @@ } @Test - public void shouldNotUpdateAddressTypeDueToError() throws Exception { + void shouldNotUpdateAddressTypeDueToError() throws Exception { AddressTypeDto addressTypeDto = MockDataHelper.mockAddressTypeDto(); addressTypeDto.setUuid(UUID.randomUUID()); @@ -114,7 +119,7 @@ } @Test - public void shouldDeleteAddressType() throws Exception { + void shouldDeleteAddressType() throws Exception { mockMvc.perform(delete("/addressTypes/05ff2344-20a5-11ea-978f-2e728ce88125") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful());
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/AssignmentModulContactControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/AssignmentModulContactControllerTest.java index 0729da2..8d47ac6 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/AssignmentModulContactControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/AssignmentModulContactControllerTest.java
@@ -36,13 +36,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class AssignmentModulContactControllerTest { +@ActiveProfiles("test") +class AssignmentModulContactControllerTest { @MockBean private AssignmentModulContactService assignmentService; @@ -51,7 +56,7 @@ private MockMvc mockMvc; @Test - public void shouldReturnAssignmentsForAContact() throws Exception { + void shouldReturnAssignmentsForAContact() throws Exception { List<AssignmentModulContactDto> listDtos = MockDataHelper.mockAssignmentModulContactDtoList(); when(assignmentService.getAssignments(any(UUID.class))).thenReturn(listDtos); @@ -63,7 +68,7 @@ @Test - public void shouldReturnAssignmentForAContact() throws Exception { + void shouldReturnAssignmentForAContact() throws Exception { AssignmentModulContactDto dto = MockDataHelper.mockAssignmentModulContactDto(); when(assignmentService.getAssignment(any(UUID.class), any(UUID.class))).thenReturn(dto); @@ -75,7 +80,7 @@ @Test - public void shouldInsertAssignment() throws Exception { + void shouldInsertAssignment() throws Exception { AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); assignmentDto.setUuid(UUID.fromString("394dce82-41af-11ea-b77f-2e728ce88125")); assignmentDto.setContactUuid(UUID.fromString("5b164ab2-41af-11ea-b77f-2e728ce88125")); @@ -103,7 +108,7 @@ @Test - public void shouldUpdateAssignment() throws Exception { + void shouldUpdateAssignment() throws Exception { AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); when( assignmentService.updateAssignment(any(UUID.class), any(AssignmentModulContactDto.class))).thenReturn(assignmentDto); @@ -113,9 +118,9 @@ .content(new ObjectMapper().writeValueAsString(assignmentDto))) .andExpect(status().is2xxSuccessful()); } -// + @Test - public void shouldNotUpdateAddress() throws Exception { + void shouldNotUpdateAddress() throws Exception { AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); when( assignmentService.updateAssignment(any(UUID.class), any(AssignmentModulContactDto.class))).thenReturn(assignmentDto); @@ -127,11 +132,9 @@ } @Test - public void shouldDeleteAddress() throws Exception { + void shouldDeleteAddress() throws Exception { mockMvc.perform(delete("/contacts/{contactUuid}/assignments/{assignmentUuid}", UUID.randomUUID(), UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful()); } - - } \ No newline at end of file
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/CommunicationControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/CommunicationControllerTest.java index 9e91048..b7732f6 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/CommunicationControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/CommunicationControllerTest.java
@@ -34,13 +34,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class CommunicationControllerTest { +@ActiveProfiles("test") +class CommunicationControllerTest { @MockBean private CommunicationService communicationService; @@ -49,7 +54,7 @@ private MockMvc mockMvc; @Test - public void shouldReturnCommunicationsForAContact() throws Exception { + void shouldReturnCommunicationsForAContact() throws Exception { List<CommunicationDto> listDtos = MockDataHelper.mockCommunicationDtoList(); when(communicationService.getCommunicationsByContactUuid(any(UUID.class))).thenReturn(listDtos); @@ -60,7 +65,7 @@ } @Test - public void shouldReturnSingleCommunication() throws Exception { + void shouldReturnSingleCommunication() throws Exception { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); when(communicationService.getCommunication(any(UUID.class), any(UUID.class))).thenReturn(communicationDto); @@ -72,7 +77,7 @@ @Test - public void shouldInsertCommunication() throws Exception { + void shouldInsertCommunication() throws Exception { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); communicationDto.setUuid(UUID.fromString("498a1874-3c2c-11ea-b77f-2e728ce88125")); @@ -97,7 +102,7 @@ @Test - public void shouldUpdateCommunication() throws Exception { + void shouldUpdateCommunication() throws Exception { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); when( communicationService.updateCommunication(any(UUID.class), any(CommunicationDto.class))).thenReturn(communicationDto); @@ -109,7 +114,7 @@ } @Test - public void shouldNotUpdateCommunication() throws Exception { + void shouldNotUpdateCommunication() throws Exception { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); when( communicationService.updateCommunication(any(UUID.class), any(CommunicationDto.class))).thenReturn(communicationDto); @@ -122,7 +127,7 @@ @Test - public void shouldNotUpdateCommunicationBecauseOfInvalidArgs() throws Exception { + void shouldNotUpdateCommunicationBecauseOfInvalidArgs() throws Exception { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); communicationDto.setCommunicationTypeUuid(null); @@ -135,7 +140,7 @@ .andExpect(status().isBadRequest()); } @Test - public void shouldDeleteCommunication() throws Exception { + void shouldDeleteCommunication() throws Exception { mockMvc.perform(delete("/contacts/{contactUuid}/communications/{communicationUuid}", UUID.randomUUID(), UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful());
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/CompanyControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/CompanyControllerTest.java index 1d47783..b2ef23b 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/CompanyControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/CompanyControllerTest.java
@@ -39,14 +39,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class CompanyControllerTest { +@ActiveProfiles("test") +class CompanyControllerTest { @MockBean private CompanyService companyService; @@ -56,7 +60,7 @@ @Test - public void shouldReturnARequestedCompany() throws Exception { + void shouldReturnARequestedCompany() throws Exception { CompanyDto ep = MockDataHelper.mockCompanyDto(); when(companyService.findCompany(any(UUID.class))).thenReturn(ep); @@ -69,7 +73,7 @@ @Test - public void shouldReturnAllCompany() throws Exception { + void shouldReturnAllCompany() throws Exception { Page<CompanyDto> epPage = MockDataHelper.mockCompanyDtoPage(); when(companyService.findCompanies(anyBoolean(), any(Pageable.class))).thenReturn(epPage); @@ -81,7 +85,7 @@ } @Test - public void shouldUpdateCompany() throws Exception { + void shouldUpdateCompany() throws Exception { CompanyDto ep = MockDataHelper.mockCompanyDto(); when( companyService.updateCompany(any(CompanyDto.class))).thenReturn(ep); @@ -93,7 +97,7 @@ } @Test - public void shouldNotUpdateCompanyDueToException() throws Exception { + void shouldNotUpdateCompanyDueToException() throws Exception { CompanyDto ep = MockDataHelper.mockCompanyDto(); when( companyService.updateCompany(any(CompanyDto.class))).thenReturn(ep); @@ -106,7 +110,7 @@ } @Test - public void shouldInsertCompany() throws Exception { + void shouldInsertCompany() throws Exception { CompanyDto companyDto = MockDataHelper.mockCompanyDto(); when( companyService.insertCompany(any(CompanyDto.class))).thenReturn(companyDto); @@ -121,7 +125,7 @@ } @Test - public void shouldReturnContactPerson() throws Exception { + void shouldReturnContactPerson() throws Exception { List<ContactPersonDto> contactPersonDtos = MockDataHelper.mockContactPersonDtos(); when( companyService.findContactPersonsToCompany(any(UUID.class), anyBoolean())).thenReturn(contactPersonDtos);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java index d0e9300..fec4eae 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java
@@ -36,14 +36,16 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class ContactControllerTest { +@ActiveProfiles("test") +class ContactControllerTest { @MockBean private ContactService contactService; @@ -53,7 +55,7 @@ @Test - public void shouldReturnAllContacts() throws Exception { + void shouldReturnAllContacts() throws Exception { Page<VwDetailedContact> retPage = MockDataHelper.mockVDetailedContactPage(); when(contactService.findDetailedContacts(any(SearchContactsFilterParams.class), any(Pageable.class))).thenReturn(retPage); @@ -65,7 +67,7 @@ } @Test - public void shouldReturnSingleContactByUuid() throws Exception { + void shouldReturnSingleContactByUuid() throws Exception { VwDetailedContact vwDetailedContact = MockDataHelper.mockVDetailedContact(); when(contactService.findDetailedContactByUuid(any(UUID.class))).thenReturn(vwDetailedContact);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactPersonControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactPersonControllerTest.java index 6a78eb7..8b1d73c 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactPersonControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactPersonControllerTest.java
@@ -27,19 +27,26 @@ import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; + import java.util.UUID; + import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class ContactPersonControllerTest { +@ActiveProfiles("test") +class ContactPersonControllerTest { @MockBean private ContactPersonService contactPersonService; @@ -49,7 +56,7 @@ @Test - public void shouldReturnARequestedContactPerson() throws Exception { + void shouldReturnARequestedContactPerson() throws Exception { ContactPersonDto cp = MockDataHelper.mockContactPersonDto(); when(contactPersonService.findContactPerson(any(UUID.class))).thenReturn(cp); @@ -61,7 +68,7 @@ } @Test - public void shouldUpdateContactPerson() throws Exception { + void shouldUpdateContactPerson() throws Exception { ContactPersonDto cp = MockDataHelper.mockContactPersonDto(); when( contactPersonService.updateContactPerson(any(ContactPersonDto.class))).thenReturn(cp); @@ -73,7 +80,7 @@ } @Test - public void shouldNotUpdateContactPersonDueToException() throws Exception { + void shouldNotUpdateContactPersonDueToException() throws Exception { ContactPersonDto cp = MockDataHelper.mockContactPersonDto(); when( contactPersonService.updateContactPerson(any(ContactPersonDto.class))).thenReturn(cp); @@ -86,7 +93,7 @@ } @Test - public void shouldInsertContactPerson() throws Exception { + void shouldInsertContactPerson() throws Exception { ContactPersonDto cp = MockDataHelper.mockContactPersonDto(); when( contactPersonService.insertContactPerson(any(ContactPersonDto.class))).thenReturn(cp); @@ -101,7 +108,7 @@ } @Test - public void shouldDeleteAddress() throws Exception { + void shouldDeleteAddress() throws Exception { mockMvc.perform(delete("/contact-persons/{contactUuid}", UUID.randomUUID(), UUID.randomUUID()) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful());
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/ExternalPersonControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/ExternalPersonControllerTest.java index e844db2..b86c676 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/ExternalPersonControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/ExternalPersonControllerTest.java
@@ -37,14 +37,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class ExternalPersonControllerTest { +@ActiveProfiles("test") +class ExternalPersonControllerTest { @MockBean private ExternalPersonService externalPersonService; @@ -54,7 +58,7 @@ @Test - public void shouldReturnARequestedExtPerson() throws Exception { + void shouldReturnARequestedExtPerson() throws Exception { ExternalPersonDto ep = MockDataHelper.mockExternalPersonDto(); when(externalPersonService.findExternalPerson(any(UUID.class))).thenReturn(ep); @@ -67,7 +71,7 @@ @Test - public void shouldReturnAllExtPerson() throws Exception { + void shouldReturnAllExtPerson() throws Exception { Page<ExternalPersonDto> epPage = MockDataHelper.mockExternalPersonDtoPage(); when(externalPersonService.findExternalPersons(anyBoolean(), any(Pageable.class))).thenReturn(epPage); @@ -79,7 +83,7 @@ } @Test - public void shouldUpdateExtPerson() throws Exception { + void shouldUpdateExtPerson() throws Exception { ExternalPersonDto ep = MockDataHelper.mockExternalPersonDto(); when( externalPersonService.updateExternalPerson(any(ExternalPersonDto.class))).thenReturn(ep); @@ -91,7 +95,7 @@ } @Test - public void shouldNotUpdateExtPersonDueToException() throws Exception { + void shouldNotUpdateExtPersonDueToException() throws Exception { ExternalPersonDto ep = MockDataHelper.mockExternalPersonDto(); when( externalPersonService.updateExternalPerson(any(ExternalPersonDto.class))).thenReturn(ep); @@ -104,7 +108,7 @@ } @Test - public void shouldInsertExtPerson() throws Exception { + void shouldInsertExtPerson() throws Exception { ExternalPersonDto ep = MockDataHelper.mockExternalPersonDto(); when( externalPersonService.insertExternalPerson(any(ExternalPersonDto.class))).thenReturn(ep);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/InternalPersonControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/InternalPersonControllerTest.java index 38e135b..f18259b 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/InternalPersonControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/InternalPersonControllerTest.java
@@ -34,16 +34,22 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class InternalPersonControllerTest { +@ActiveProfiles("test") +class InternalPersonControllerTest { @MockBean private InternalPersonService internalPersonService; @@ -53,7 +59,7 @@ @Test - public void shouldReturnARequestedIntPerson() throws Exception { + void shouldReturnARequestedIntPerson() throws Exception { InternalPersonDto ip = MockDataHelper.mockInternalPersonDto(); when(internalPersonService.findInternalPerson(any(UUID.class))).thenReturn(ip); @@ -66,7 +72,7 @@ @Test - public void shouldReturnAllIntPersons() throws Exception { + void shouldReturnAllIntPersons() throws Exception { Page<InternalPersonDto> ipPage = MockDataHelper.mockInternalPersonDtoPage(); when(internalPersonService.findInternalPersons(anyBoolean(), anyString(), anyString(), any(Pageable.class))).thenReturn(ipPage); @@ -78,7 +84,7 @@ } @Test - public void shouldUpdateIntPerson() throws Exception { + void shouldUpdateIntPerson() throws Exception { InternalPersonDto ip = MockDataHelper.mockInternalPersonDto(); when( internalPersonService.updateInternalPerson(any(InternalPersonDto.class))).thenReturn(ip); @@ -90,7 +96,7 @@ } @Test - public void shouldNotUpdateIntPersonDueToException() throws Exception { + void shouldNotUpdateIntPersonDueToException() throws Exception { InternalPersonDto ip = MockDataHelper.mockInternalPersonDto(); when( internalPersonService.updateInternalPerson(any(InternalPersonDto.class))).thenReturn(ip); @@ -103,7 +109,7 @@ } @Test - public void shouldInsertIntPerson() throws Exception { + void shouldInsertIntPerson() throws Exception { InternalPersonDto ip = MockDataHelper.mockInternalPersonDto(); when( internalPersonService.insertInternalPerson(any(InternalPersonDto.class))).thenReturn(ip);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/PersonTypeControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/PersonTypeControllerTest.java index d5acbec..c47e33a 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/PersonTypeControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/PersonTypeControllerTest.java
@@ -34,13 +34,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class PersonTypeControllerTest { +@ActiveProfiles("test") +class PersonTypeControllerTest { @MockBean private PersonTypeService personTypeService; @@ -49,7 +54,7 @@ private MockMvc mockMvc; @Test - public void shouldReturnAllPersonTypes() throws Exception { + void shouldReturnAllPersonTypes() throws Exception { List<PersonTypeDto> sds = MockDataHelper.mockPersonTypesDtos(); when(personTypeService.findAllPersonTypes()).thenReturn(sds); @@ -60,7 +65,7 @@ } @Test - public void shouldReturnSinglePersonType() throws Exception { + void shouldReturnSinglePersonType() throws Exception { PersonTypeDto personTypeDto = MockDataHelper.mockPersonTypeDto(); when(personTypeService.getPersonTypeByUuid(any(UUID.class))).thenReturn(personTypeDto); @@ -71,7 +76,7 @@ } @Test - public void shouldInsertPersonType() throws Exception { + void shouldInsertPersonType() throws Exception { PersonTypeDto personTypeDto = MockDataHelper.mockPersonTypeDto(); personTypeDto.setType("Master"); personTypeDto.setDescription("of the universe"); @@ -87,7 +92,7 @@ } @Test - public void shouldUpdatePersonType() throws Exception { + void shouldUpdatePersonType() throws Exception { PersonTypeDto personTypeDto = MockDataHelper.mockPersonTypeDto(); personTypeDto.setUuid(UUID.randomUUID()); @@ -100,7 +105,7 @@ } @Test - public void shouldNotUpdatePersonTypeDueToError() throws Exception { + void shouldNotUpdatePersonTypeDueToError() throws Exception { PersonTypeDto personTypeDto = MockDataHelper.mockPersonTypeDto(); personTypeDto.setUuid(UUID.randomUUID()); @@ -114,7 +119,7 @@ } @Test - public void shouldDeletePersonType() throws Exception { + void shouldDeletePersonType() throws Exception { mockMvc.perform(delete("/personTypes/05ff2344-20a5-11ea-978f-2e728ce88125") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful());
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/SalutationControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/SalutationControllerTest.java index b743ca7..b413ba2 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/SalutationControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/SalutationControllerTest.java
@@ -28,17 +28,24 @@ import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; + import java.util.List; import java.util.UUID; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @SpringBootTest(classes = ContactBaseDataApplication.class) @AutoConfigureMockMvc -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class SalutationControllerTest { +@ActiveProfiles("test") +class SalutationControllerTest { @MockBean private SalutationService saluationService; @@ -47,7 +54,7 @@ private MockMvc mockMvc; @Test - public void shouldReturnAllSalutations() throws Exception { + void shouldReturnAllSalutations() throws Exception { List<SalutationDto> sds = MockDataHelper.mockSalutationsDtos(); when(saluationService.findAllSalutations()).thenReturn(sds); @@ -58,7 +65,7 @@ } @Test - public void shouldReturnSingleSalutation() throws Exception { + void shouldReturnSingleSalutation() throws Exception { SalutationDto salutationDto = MockDataHelper.mockSalutationDto(); when(saluationService.getSalutationByUuid(any(UUID.class))).thenReturn(salutationDto); @@ -69,7 +76,7 @@ } @Test - public void shouldInsertSalutation() throws Exception { + void shouldInsertSalutation() throws Exception { SalutationDto salutationDto = MockDataHelper.mockSalutationDto(); salutationDto.setType("Master"); salutationDto.setDescription("of the universe"); @@ -85,7 +92,7 @@ } @Test - public void shouldUpdateSalutation() throws Exception { + void shouldUpdateSalutation() throws Exception { SalutationDto salutationDto = MockDataHelper.mockSalutationDto(); salutationDto.setUuid(UUID.randomUUID()); @@ -98,7 +105,7 @@ } @Test - public void shouldNotUpdateSalutationDueToError() throws Exception { + void shouldNotUpdateSalutationDueToError() throws Exception { SalutationDto salutationDto = MockDataHelper.mockSalutationDto(); salutationDto.setUuid(UUID.randomUUID()); @@ -112,7 +119,7 @@ } @Test - public void shouldDeleteSalutation() throws Exception { + void shouldDeleteSalutation() throws Exception { mockMvc.perform(delete("/salutations/05ff2344-20a5-11ea-978f-2e728ce88125") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().is2xxSuccessful());
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/AddressServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/AddressServiceTest.java index ff0bee5..92bc7b4 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/AddressServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/AddressServiceTest.java
@@ -18,16 +18,13 @@ import org.eclipse.openk.contactbasedata.exceptions.NotFoundException; import org.eclipse.openk.contactbasedata.exceptions.OperationDeniedException; import org.eclipse.openk.contactbasedata.model.RefAddressType; -import org.eclipse.openk.contactbasedata.model.RefSalutation; import org.eclipse.openk.contactbasedata.model.TblAddress; import org.eclipse.openk.contactbasedata.model.TblContact; import org.eclipse.openk.contactbasedata.repository.AddressRepository; import org.eclipse.openk.contactbasedata.repository.AddressTypeRepository; import org.eclipse.openk.contactbasedata.repository.ContactRepository; -import org.eclipse.openk.contactbasedata.repository.SalutationRepository; import org.eclipse.openk.contactbasedata.support.MockDataHelper; import org.eclipse.openk.contactbasedata.viewmodel.AddressDto; -import org.eclipse.openk.contactbasedata.viewmodel.SalutationDto; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.mockito.stubbing.Answer; @@ -35,6 +32,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.List; @@ -44,14 +42,17 @@ import static org.hibernate.validator.internal.util.Contracts.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class AddressServiceTest { +@ActiveProfiles("test") +class AddressServiceTest { @Qualifier("myAddressService") @Autowired private AddressService addressService; @@ -66,17 +67,17 @@ private AddressTypeRepository addressTypeRepository; @Test - public void shouldReturnAddressesByContactUuid() { + void shouldReturnAddressesByContactUuid() { List<TblAddress> listTblAddresses = MockDataHelper.mockTblAddressList(); when(addressRepository.findByTblContactUuid( any(UUID.class)) ).thenReturn(listTblAddresses); List<AddressDto> dtoList = addressService.getAddressesByContactUuid(UUID.randomUUID()); - assertEquals(dtoList.size(), 2 ); + assertEquals(2, dtoList.size() ); } @Test - public void shouldReturnAddressesByContactUuidAndAddressUuid() { + void shouldReturnAddressesByContactUuidAndAddressUuid() { TblAddress tblAddress = MockDataHelper.mockTblAddress(); when(addressRepository.findByUuid( any(UUID.class)) ).thenReturn(Optional.of(tblAddress)); @@ -86,7 +87,7 @@ } @Test - public void shouldUpdateAddress() { + void shouldUpdateAddress() { AddressDto addressDto = MockDataHelper.mockAddressDto(); TblAddress tblAddress = MockDataHelper.mockTblAddress(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -116,7 +117,7 @@ } @Test - public void shouldNotUpdateAddress_Exception1() { + void shouldNotUpdateAddress_Exception1() { AddressDto addressDto = MockDataHelper.mockAddressDto(); TblAddress tblAddress = MockDataHelper.mockTblAddress(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -136,7 +137,7 @@ } @Test - public void shouldNotUpdateAddress_Exception2() { + void shouldNotUpdateAddress_Exception2() { AddressDto addressDto = MockDataHelper.mockAddressDto(); TblAddress tblAddress = MockDataHelper.mockTblAddress(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -155,7 +156,7 @@ } @Test - public void shouldNotUpdateAddress_Exception3() { + void shouldNotUpdateAddress_Exception3() { AddressDto addressDto = MockDataHelper.mockAddressDto(); addressDto.setIsMainAddress(true); TblAddress tblAddress = MockDataHelper.mockTblAddress(); @@ -180,7 +181,7 @@ } @Test - public void shouldInsertAddress() { + void shouldInsertAddress() { AddressDto addressDto = MockDataHelper.mockAddressDto(); TblAddress tblAddress = MockDataHelper.mockTblAddress(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -211,7 +212,7 @@ } @Test - public void shouldNotInsertAddress_Exception_1() { + void shouldNotInsertAddress_Exception_1() { AddressDto addressDto = MockDataHelper.mockAddressDto(); TblAddress tblAddress = MockDataHelper.mockTblAddress(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -227,7 +228,7 @@ } @Test - public void shouldNotInsertAddress_Exception_2() { + void shouldNotInsertAddress_Exception_2() { AddressDto addressDto = MockDataHelper.mockAddressDto(); TblAddress tblAddress = MockDataHelper.mockTblAddress(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -243,7 +244,7 @@ @Test - public void shouldNotInsertAddress_Exception3() { + void shouldNotInsertAddress_Exception3() { AddressDto addressDto = MockDataHelper.mockAddressDto(); addressDto.setIsMainAddress(true); TblAddress tblAddress = MockDataHelper.mockTblAddress(); @@ -261,7 +262,7 @@ @Test - public void shouldDeleteAddress() { + void shouldDeleteAddress() { TblAddress tblAddress = MockDataHelper.mockTblAddress(); TblContact tblContact = MockDataHelper.mockTblContact(); tblAddress.setTblContact(tblContact);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/AddressTypeServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/AddressTypeServiceTest.java index fe46a15..292feb4 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/AddressTypeServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/AddressTypeServiceTest.java
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.List; @@ -40,8 +41,8 @@ @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class AddressTypeServiceTest { +@ActiveProfiles("test") +class AddressTypeServiceTest { @Qualifier("myAddressTypeService") @Autowired private AddressTypeService addressTypeService; @@ -50,19 +51,19 @@ private AddressTypeRepository addressTypeRepository; @Test - public void shouldFindAllAddressTypesProperly() { + void shouldFindAllAddressTypesProperly() { List<RefAddressType> rs = MockDataHelper.mockRefAddressTypes(); when(addressTypeRepository.findAll()).thenReturn(rs); List<AddressTypeDto> retVals = addressTypeService.findAllAddressTypes(); assertEquals(rs.size(), retVals.size()); - assertEquals(rs.size(), 2); + assertEquals(2, rs.size()); assertEquals(rs.get(1).getUuid(), retVals.get(1).getUuid()); } @Test - public void shouldReturnAddressTypeByUuid() { + void shouldReturnAddressTypeByUuid() { RefAddressType refAddressType = MockDataHelper.mockRefAddressType(); refAddressType.setType("Testtyp"); @@ -74,7 +75,7 @@ } @Test - public void shouldInsertAddressType(){ + void shouldInsertAddressType(){ RefAddressType refAddressType = MockDataHelper.mockRefAddressType(); refAddressType.setUuid(UUID.fromString("1468275e-200b-11ea-978f-2e728ce88125")); @@ -92,7 +93,7 @@ } @Test - public void shouldUpdateAddressType() { + void shouldUpdateAddressType() { RefAddressType addressType = MockDataHelper.mockRefAddressType(); addressType.setType("Viertadresse"); @@ -110,7 +111,7 @@ @Test - public void shouldDeleteAddressType() { + void shouldDeleteAddressType() { RefAddressType addressType = MockDataHelper.mockRefAddressType();
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/AssignmentModulContactServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/AssignmentModulContactServiceTest.java index 92b9a83..dc79e6e 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/AssignmentModulContactServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/AssignmentModulContactServiceTest.java
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.List; @@ -38,14 +39,17 @@ import static org.hibernate.validator.internal.util.Contracts.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class AssignmentModulContactServiceTest { +@ActiveProfiles("test") +class AssignmentModulContactServiceTest { @Qualifier("myAssignmentModulContactService") @Autowired private AssignmentModulContactService assignmentService; @@ -58,18 +62,18 @@ @Test - public void shouldReturnAssignmentsByContactUuid() { + void shouldReturnAssignmentsByContactUuid() { List<TblAssignmentModulContact> listTblAssignments = MockDataHelper.mockTblAssignmentsList(); when(assignmentRepository.findByTblContactUuid( any(UUID.class)) ).thenReturn(listTblAssignments); List<AssignmentModulContactDto> tblAssignmentsList = assignmentService.getAssignments(UUID.randomUUID()); - assertEquals(tblAssignmentsList.size(), 2 ); + assertEquals(2, tblAssignmentsList.size() ); } @Test - public void shouldReturnSingleAssignmentsByContactUuidAndAssignUuid() { + void shouldReturnSingleAssignmentsByContactUuidAndAssignUuid() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); when(assignmentRepository.findByUuid(any(UUID.class)) ).thenReturn(Optional.of(tblAssignment)); @@ -86,7 +90,7 @@ assignmentService.getAssignment(assignmentDto.getContactUuid(), UUID.randomUUID())); } @Test - public void shouldUpdateAssignment() { + void shouldUpdateAssignment() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -109,7 +113,7 @@ } @Test - public void shouldNotUpdateAssignment_Exception1() { + void shouldNotUpdateAssignment_Exception1() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -124,7 +128,7 @@ } @Test - public void shouldNotUpdateAssignment_Exception2() { + void shouldNotUpdateAssignment_Exception2() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -139,7 +143,7 @@ } @Test - public void shouldNotUpdateAssignment_Exception3() { + void shouldNotUpdateAssignment_Exception3() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -155,7 +159,7 @@ } @Test - public void shouldInsertAssignment() { + void shouldInsertAssignment() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -179,7 +183,7 @@ } @Test - public void shouldNotInsertAssignment_Exception_1() { + void shouldNotInsertAssignment_Exception_1() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -196,7 +200,7 @@ @Test - public void shouldNotInsertAssignment_Exception_2() { + void shouldNotInsertAssignment_Exception_2() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); AssignmentModulContactDto assignmentDto = MockDataHelper.mockAssignmentModulContactDto(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -212,7 +216,7 @@ @Test - public void shouldDeleteAssignment() { + void shouldDeleteAssignment() { TblAssignmentModulContact tblAssignment = MockDataHelper.mockTblAssignmentModulContact(); TblContact tblContact = MockDataHelper.mockTblContact(); tblAssignment.setTblContact(tblContact);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/AuthNAuthServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/AuthNAuthServiceTest.java index 27aba4b..f90378d 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/AuthNAuthServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/AuthNAuthServiceTest.java
@@ -29,17 +29,21 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.List; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class AuthNAuthServiceTest { +@ActiveProfiles("test") +class AuthNAuthServiceTest { private static final long MAIL_ID = 1L; private static final long TEL_ID = 2L; @@ -60,7 +64,7 @@ private CommunicationTypeRepository communicationTypeRepository; @Test - public void shouldSynchronizeAuthnAuthRunThrou1() { + void shouldSynchronizeAuthnAuthRunThrou1() { List<TblInternalPerson> internalPeople = MockDataHelper.mockTblInternalPersonPage().getContent(); internalPeople.get(1).setUserRef("karlK"); when(internalPersonRepository.saveAll(any( List.class ))).thenReturn(Lists.emptyList());
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationServiceTest.java index ac52b17..d4a8a78 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationServiceTest.java
@@ -17,8 +17,13 @@ import org.eclipse.openk.contactbasedata.config.TestConfiguration; import org.eclipse.openk.contactbasedata.exceptions.NotFoundException; import org.eclipse.openk.contactbasedata.exceptions.OperationDeniedException; -import org.eclipse.openk.contactbasedata.model.*; -import org.eclipse.openk.contactbasedata.repository.*; +import org.eclipse.openk.contactbasedata.model.RefCommunicationType; +import org.eclipse.openk.contactbasedata.model.TblAddress; +import org.eclipse.openk.contactbasedata.model.TblCommunication; +import org.eclipse.openk.contactbasedata.model.TblContact; +import org.eclipse.openk.contactbasedata.repository.CommunicationRepository; +import org.eclipse.openk.contactbasedata.repository.CommunicationTypeRepository; +import org.eclipse.openk.contactbasedata.repository.ContactRepository; import org.eclipse.openk.contactbasedata.support.MockDataHelper; import org.eclipse.openk.contactbasedata.viewmodel.CommunicationDto; import org.junit.jupiter.api.Test; @@ -28,21 +33,26 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; + import java.util.List; import java.util.Optional; import java.util.UUID; + import static org.hibernate.validator.internal.util.Contracts.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class CommunicationServiceTest { +@ActiveProfiles("test") +class CommunicationServiceTest { @Qualifier("myCommunicationService") @Autowired private CommunicationService communicationService; @@ -57,17 +67,17 @@ private CommunicationTypeRepository communicationTypeRepository; @Test - public void shouldReturnAddressesByContactUuid() { + void shouldReturnAddressesByContactUuid() { List<TblCommunication> listTblCommunications = MockDataHelper.mockTblCommunicationsList(); when(communicationRepository.findByTblContactUuid( any(UUID.class)) ).thenReturn(listTblCommunications); List<CommunicationDto> dtoList = communicationService.getCommunicationsByContactUuid(UUID.randomUUID()); - assertEquals(dtoList.size(), 2 ); + assertEquals(2, dtoList.size() ); } @Test - public void shouldReturnCommunicationsByContactUuidAndCommunicationUuid() { + void shouldReturnCommunicationsByContactUuidAndCommunicationUuid() { TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); when(communicationRepository.findByUuid( any(UUID.class)) ).thenReturn(Optional.of(tblCommunication)); @@ -77,7 +87,7 @@ } @Test - public void shouldUpdateCommunication() { + void shouldUpdateCommunication() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -99,7 +109,7 @@ } @Test - public void shouldNotUpdateCommunication_Exception1() { + void shouldNotUpdateCommunication_Exception1() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -119,7 +129,7 @@ } @Test - public void shouldNotUpdateCommunication_Exception2() { + void shouldNotUpdateCommunication_Exception2() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -140,7 +150,7 @@ } @Test - public void shouldNotUpdateCommunication_Exception3() { + void shouldNotUpdateCommunication_Exception3() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -163,7 +173,7 @@ } @Test - public void shouldInsertCommunication() { + void shouldInsertCommunication() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -184,7 +194,7 @@ } @Test - public void shouldNotInsertCommunication_Exception_1() { + void shouldNotInsertCommunication_Exception_1() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -200,7 +210,7 @@ } @Test - public void shouldNotInsertCommunication_Exception_2() { + void shouldNotInsertCommunication_Exception_2() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); @@ -216,7 +226,7 @@ @Test - public void shouldNotInsertCommunication_Exception3() { + void shouldNotInsertCommunication_Exception3() { CommunicationDto communicationDto = MockDataHelper.mockCommunicationDto(); TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); RefCommunicationType refCommunicationType = MockDataHelper.mockRefCommunicationType(); @@ -234,7 +244,7 @@ @Test - public void shouldDeleteCommunication() { + void shouldDeleteCommunication() { TblCommunication tblCommunication = MockDataHelper.mockTblCommunication(); TblContact tblContact = MockDataHelper.mockTblContact(); tblCommunication.setTblContact(tblContact);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationTypeServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationTypeServiceTest.java index 1121c09..6e641b3 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationTypeServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/CommunicationTypeServiceTest.java
@@ -16,18 +16,16 @@ import org.eclipse.openk.contactbasedata.config.TestConfiguration; import org.eclipse.openk.contactbasedata.model.RefCommunicationType; -import org.eclipse.openk.contactbasedata.model.RefSalutation; import org.eclipse.openk.contactbasedata.repository.CommunicationTypeRepository; -import org.eclipse.openk.contactbasedata.repository.SalutationRepository; import org.eclipse.openk.contactbasedata.support.MockDataHelper; import org.eclipse.openk.contactbasedata.viewmodel.CommunicationTypeDto; -import org.eclipse.openk.contactbasedata.viewmodel.SalutationDto; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.List; @@ -43,8 +41,8 @@ @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class CommunicationTypeServiceTest { +@ActiveProfiles("test") +class CommunicationTypeServiceTest { @Qualifier("myCommunicationTypeService") @Autowired private CommunicationTypeService communicationTypeService; @@ -53,19 +51,19 @@ private CommunicationTypeRepository communicationTypeRepository; @Test - public void shouldFindAllCommunicationTypes() { + void shouldFindAllCommunicationTypes() { List<RefCommunicationType> rct = MockDataHelper.mockRefCommunicationTypeList(); when(communicationTypeRepository.findAll()).thenReturn(rct); List<CommunicationTypeDto> retVals = communicationTypeService.findCommunicationTypes(); assertEquals(rct.size(), retVals.size()); - assertEquals(rct.size(), 3); + assertEquals(3, rct.size()); assertEquals(rct.get(1).getUuid(), retVals.get(1).getUuid()); } @Test - public void shouldReturnCommunicationTypeByUuid() { + void shouldReturnCommunicationTypeByUuid() { RefCommunicationType rct = MockDataHelper.mockRefCommunicationType(); rct.setType("Testtyp"); @@ -77,7 +75,7 @@ } @Test - public void shouldInsertCommunicationType(){ + void shouldInsertCommunicationType(){ RefCommunicationType rfc = MockDataHelper.mockRefCommunicationType(); rfc.setUuid(UUID.fromString("b1a9b6de-3129-11ea-978f-2e728ce88125")); @@ -95,7 +93,7 @@ } @Test - public void shouldUpdateCommunicationType() { + void shouldUpdateCommunicationType() { RefCommunicationType rfc = MockDataHelper.mockRefCommunicationType(); rfc.setType("Rauchzeichen"); @@ -113,7 +111,7 @@ @Test - public void shouldDeleteCommunicationType() { + void shouldDeleteCommunicationType() { RefCommunicationType rft = MockDataHelper.mockRefCommunicationType();
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/CompanyServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/CompanyServiceTest.java index fb6d18e..533e7d6 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/CompanyServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/CompanyServiceTest.java
@@ -33,20 +33,26 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.List; import java.util.Optional; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class CompanyServiceTest { +@ActiveProfiles("test") +class CompanyServiceTest { @Qualifier("myCompanyService") @Autowired private CompanyService companyService; @@ -64,7 +70,7 @@ private PersonTypeRepository personTypeRepository; @Test - public void shouldFindACompanyProperly() { + void shouldFindACompanyProperly() { TblCompany ep = MockDataHelper.mockCompany(); when(companyRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(ep)); CompanyDto dto = companyService.findCompany(UUID.randomUUID()); @@ -74,7 +80,7 @@ @Test - public void shouldFindSeveralCompaniesProperly() { + void shouldFindSeveralCompaniesProperly() { Page<TblCompany> page1 = MockDataHelper.mockCompanyPage(); Page<TblCompany> page2 = MockDataHelper.mockCompanyPage(); when(companyRepository.findAll(any(Pageable.class))).thenReturn(page1); @@ -91,14 +97,14 @@ .findByContact_anonymizedFalseOrContact_anonymizedIsNull(any(Pageable.class)); } @Test - public void shouldThrowInErrorCaseWithCompany() { + void shouldThrowInErrorCaseWithCompany() { TblCompany ep = MockDataHelper.mockCompany(); when(companyRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); assertThrows(NotFoundException.class, () -> companyService.findCompany(UUID.randomUUID())); } @Test - public void shouldUpdateCompany() { + void shouldUpdateCompany() { CompanyDto epDto = MockDataHelper.mockCompanyDto(); TblCompany epTbl = MockDataHelper.mockCompany(); when(companyRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(epTbl)); @@ -122,7 +128,7 @@ } @Test - public void shouldNotUpdateCompany_Exception1() { + void shouldNotUpdateCompany_Exception1() { CompanyDto epDto = MockDataHelper.mockCompanyDto(); TblCompany epTbl = MockDataHelper.mockCompany(); when(companyRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); @@ -141,7 +147,7 @@ } @Test - public void shouldInsertCompany() { + void shouldInsertCompany() { CompanyDto epDto = MockDataHelper.mockCompanyDto(); epDto.setContactUuid(null); @@ -165,7 +171,7 @@ } @Test - public void findContactPersonsToCompanyWithSuccess() { + void findContactPersonsToCompanyWithSuccess() { TblCompany company = MockDataHelper.mockCompany(); company.setContactPersons( MockDataHelper.mockTblContactPersons()); company.getContactPersons().get(1).getContact().setAnonymized(true); @@ -180,7 +186,7 @@ @Test - public void findContactPersonsToCompanyWithException() { + void findContactPersonsToCompanyWithException() { when(companyRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); assertThrows( NotFoundException.class, ()-> companyService.findContactPersonsToCompany(UUID.randomUUID(), false)); }
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactAnonymizerServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactAnonymizerServiceTest.java index 60906b5..5062700 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactAnonymizerServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactAnonymizerServiceTest.java
@@ -18,24 +18,34 @@ import org.eclipse.openk.contactbasedata.constants.Constants; import org.eclipse.openk.contactbasedata.model.TblContact; import org.eclipse.openk.contactbasedata.support.MockDataHelper; -import org.eclipse.openk.contactbasedata.viewmodel.*; +import org.eclipse.openk.contactbasedata.viewmodel.AddressDto; +import org.eclipse.openk.contactbasedata.viewmodel.CommunicationDto; +import org.eclipse.openk.contactbasedata.viewmodel.CompanyDto; +import org.eclipse.openk.contactbasedata.viewmodel.ContactPersonDto; +import org.eclipse.openk.contactbasedata.viewmodel.ExternalPersonDto; +import org.eclipse.openk.contactbasedata.viewmodel.InternalPersonDto; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) -public class ContactAnonymizerServiceTest { +@ActiveProfiles("test") +class ContactAnonymizerServiceTest { @Qualifier("myContactAnonymizerService") @Autowired private ContactAnonymizerService contactAnonymizerService; @@ -62,7 +72,7 @@ private CommunicationService communicationService; @Test - public void shouldAnonymizeInternalPerson() { + void shouldAnonymizeInternalPerson() { UUID theContactUuid = UUID.randomUUID(); TblContact tblIntPers = MockDataHelper.mockTblContact(); tblIntPers.setUuid(theContactUuid); @@ -95,7 +105,7 @@ } @Test - public void shouldAnonymizeExternalPerson() { + void shouldAnonymizeExternalPerson() { UUID theContactUuid = UUID.randomUUID(); TblContact tblExtPers = MockDataHelper.mockTblContact(); tblExtPers.setUuid(theContactUuid); @@ -126,7 +136,7 @@ @Test - public void shouldAnonymizeCompany() { + void shouldAnonymizeCompany() { UUID theContactUuid = UUID.randomUUID(); TblContact tblCompany = MockDataHelper.mockTblContact(); tblCompany.setUuid(theContactUuid);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactPersonServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactPersonServiceTest.java index ef3a722..640c5e7 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactPersonServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactPersonServiceTest.java
@@ -16,8 +16,16 @@ import org.eclipse.openk.contactbasedata.config.TestConfiguration; import org.eclipse.openk.contactbasedata.exceptions.NotFoundException; -import org.eclipse.openk.contactbasedata.model.*; -import org.eclipse.openk.contactbasedata.repository.*; +import org.eclipse.openk.contactbasedata.model.RefPersonType; +import org.eclipse.openk.contactbasedata.model.RefSalutation; +import org.eclipse.openk.contactbasedata.model.TblCompany; +import org.eclipse.openk.contactbasedata.model.TblContact; +import org.eclipse.openk.contactbasedata.model.TblContactPerson; +import org.eclipse.openk.contactbasedata.repository.CompanyRepository; +import org.eclipse.openk.contactbasedata.repository.ContactPersonRepository; +import org.eclipse.openk.contactbasedata.repository.ContactRepository; +import org.eclipse.openk.contactbasedata.repository.PersonTypeRepository; +import org.eclipse.openk.contactbasedata.repository.SalutationRepository; import org.eclipse.openk.contactbasedata.support.MockDataHelper; import org.eclipse.openk.contactbasedata.viewmodel.ContactPersonDto; import org.junit.jupiter.api.Test; @@ -27,10 +35,15 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; + import java.util.Optional; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; @@ -38,8 +51,8 @@ @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class ContactPersonServiceTest { +@ActiveProfiles("test") +class ContactPersonServiceTest { @Qualifier("myContactPersonService") @Autowired private ContactPersonService contactPersonService; @@ -60,7 +73,7 @@ private CompanyRepository companyRepository; @Test - public void shouldFindAContactPersonProperly() { + void shouldFindAContactPersonProperly() { TblContactPerson cp = MockDataHelper.mockTblContactPerson(); when(contactPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(cp)); ContactPersonDto dto = contactPersonService.findContactPerson(UUID.randomUUID()); @@ -69,14 +82,14 @@ } @Test - public void shouldThrowNotFoundErrorContactPerson() { + void shouldThrowNotFoundErrorContactPerson() { TblContactPerson cp = MockDataHelper.mockTblContactPerson(); when(contactPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); assertThrows(NotFoundException.class, () -> contactPersonService.findContactPerson(UUID.randomUUID())); } @Test - public void shouldUpdateContactPerson() { + void shouldUpdateContactPerson() { ContactPersonDto cpDto = MockDataHelper.mockContactPersonDto(); TblContactPerson cpTbl = MockDataHelper.mockTblContactPerson(); @@ -109,7 +122,7 @@ @Test - public void shouldNotUpdateContactPerson_Exception1() { + void shouldNotUpdateContactPerson_Exception1() { ContactPersonDto epDto = MockDataHelper.mockContactPersonDto(); TblContactPerson cpTbl = MockDataHelper.mockTblContactPerson(); when(contactPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); @@ -128,7 +141,7 @@ } @Test - public void shouldNotUpdateContactPerson_Exception2() { + void shouldNotUpdateContactPerson_Exception2() { ContactPersonDto cpDto = MockDataHelper.mockContactPersonDto(); TblContactPerson cpTbl = MockDataHelper.mockTblContactPerson(); when(contactPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(cpTbl)); @@ -148,7 +161,7 @@ @Test - public void shouldInsertContactPerson() { + void shouldInsertContactPerson() { ContactPersonDto cpDto = MockDataHelper.mockContactPersonDto(); cpDto.setContactUuid(null); RefSalutation refSalutation = MockDataHelper.mockRefSalutation(); @@ -181,7 +194,7 @@ } @Test - public void shouldDeleteContactPerson() { + void shouldDeleteContactPerson() { TblContactPerson tblContactPerson = MockDataHelper.mockTblContactPerson(); TblContact tblContact = MockDataHelper.mockTblContact(); tblContactPerson.setContact(tblContact);
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java index c8d9cb4..65623b4 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java
@@ -27,6 +27,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.Date; @@ -34,14 +35,16 @@ import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.when; //@RunWith(SpringRunner.class) @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class ContactServiceTest { +@ActiveProfiles("test") +class ContactServiceTest { @Qualifier("myContactService") @Autowired private ContactService contactService; @@ -50,7 +53,7 @@ private DetailedContactRepository detailedContactRepository; @Test - public void shouldFindDetailedContactsProperly() { + void shouldFindDetailedContactsProperly() { Page<VwDetailedContact> mockPaged = MockDataHelper.mockVDetailedContactPage(); when(detailedContactRepository.findByFilter(isNull(), isNull(), isNull(), isNull(), anyBoolean(), any( Date.class), anyBoolean(), anyBoolean(), anyBoolean(), any(Pageable.class))).thenReturn(mockPaged); @@ -62,7 +65,7 @@ } @Test - public void shouldFindSingleDetailedContactProperly() { + void shouldFindSingleDetailedContactProperly() { VwDetailedContact mockContact = MockDataHelper.mockVDetailedContact(); when(detailedContactRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(mockContact));
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/ExternalPersonServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/ExternalPersonServiceTest.java index 0bfe889..952d758 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/ExternalPersonServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/ExternalPersonServiceTest.java
@@ -34,19 +34,25 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.Optional; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class ExternalPersonServiceTest { +@ActiveProfiles("test") +class ExternalPersonServiceTest { @Qualifier("myExternalPersonService") @Autowired private ExternalPersonService externalPersonService; @@ -64,7 +70,7 @@ private PersonTypeRepository personTypeRepository; @Test - public void shouldFindAnExternalPersonProperly() { + void shouldFindAnExternalPersonProperly() { TblExternalPerson ep = MockDataHelper.mockExternalPerson(); when(externalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(ep)); ExternalPersonDto dto = externalPersonService.findExternalPerson(UUID.randomUUID()); @@ -73,7 +79,7 @@ } @Test - public void shouldFindSeveralExternalPersonsProperly() { + void shouldFindSeveralExternalPersonsProperly() { Page<TblExternalPerson> page1 = MockDataHelper.mockExternalPersonPage(); Page<TblExternalPerson> page2 = MockDataHelper.mockExternalPersonPage(); when(externalPersonRepository.findAll(any(Pageable.class))).thenReturn(page1); @@ -91,14 +97,14 @@ } @Test - public void shouldThrowInErrorCaseWithExternalPerson() { + void shouldThrowInErrorCaseWithExternalPerson() { TblExternalPerson ep = MockDataHelper.mockExternalPerson(); when(externalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); assertThrows(NotFoundException.class, () -> externalPersonService.findExternalPerson(UUID.randomUUID())); } @Test - public void shouldUpdateExternalPerson() { + void shouldUpdateExternalPerson() { ExternalPersonDto epDto = MockDataHelper.mockExternalPersonDto(); TblExternalPerson epTbl = MockDataHelper.mockExternalPerson(); when(externalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(epTbl)); @@ -125,7 +131,7 @@ } @Test - public void shouldNotUpdateExternalPerson_Exception1() { + void shouldNotUpdateExternalPerson_Exception1() { ExternalPersonDto epDto = MockDataHelper.mockExternalPersonDto(); TblExternalPerson epTbl = MockDataHelper.mockExternalPerson(); when(externalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); @@ -144,7 +150,7 @@ } @Test - public void shouldNotUpdateExternalPerson_Exception2() { + void shouldNotUpdateExternalPerson_Exception2() { ExternalPersonDto epDto = MockDataHelper.mockExternalPersonDto(); TblExternalPerson epTbl = MockDataHelper.mockExternalPerson(); when(externalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(epTbl)); @@ -162,7 +168,7 @@ assertThrows( NotFoundException.class, () -> externalPersonService.updateExternalPerson(epDto)); } @Test - public void shouldNotUpdateExternalPerson_Exception3() { + void shouldNotUpdateExternalPerson_Exception3() { ExternalPersonDto epDto = MockDataHelper.mockExternalPersonDto(); TblExternalPerson epTbl = MockDataHelper.mockExternalPerson(); when(externalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(epTbl)); @@ -181,7 +187,7 @@ } @Test - public void shouldInsertExternalPerson() { + void shouldInsertExternalPerson() { ExternalPersonDto epDto = MockDataHelper.mockExternalPersonDto(); epDto.setContactUuid(null); RefSalutation refSalutation = MockDataHelper.mockRefSalutation();
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/InternalPersonServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/InternalPersonServiceTest.java index b40b879..5475968 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/InternalPersonServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/InternalPersonServiceTest.java
@@ -34,20 +34,25 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.Optional; import java.util.UUID; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class InternalPersonServiceTest { +@ActiveProfiles("test") +class InternalPersonServiceTest { @Qualifier("myInternalPersonService") @Autowired private InternalPersonService internalPersonService; @@ -65,7 +70,7 @@ private PersonTypeRepository personTypeRepository; @Test - public void shouldFindAnInternalPersonProperly() { + void shouldFindAnInternalPersonProperly() { TblInternalPerson ip = MockDataHelper.mockInternalPerson(); when(internalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(ip)); InternalPersonDto dto = internalPersonService.findInternalPerson(UUID.randomUUID()); @@ -74,7 +79,7 @@ } @Test - public void shouldFindAllInternalPersons() { + void shouldFindAllInternalPersons() { Page<TblInternalPerson> ipPage = MockDataHelper.mockTblInternalPersonPage(); when(internalPersonRepository.findAll(any(Pageable.class))).thenReturn(ipPage); when(internalPersonRepository.findByFilter(anyString(), anyString(), any(Pageable.class))).thenReturn(ipPage); @@ -91,14 +96,14 @@ } @Test - public void shouldThrowInErrorCaseWithInternalPerson() { + void shouldThrowInErrorCaseWithInternalPerson() { TblInternalPerson ip = MockDataHelper.mockInternalPerson(); when(internalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); assertThrows(NotFoundException.class, () -> internalPersonService.findInternalPerson(UUID.randomUUID())); } @Test - public void shouldUpdateInternalPerson() { + void shouldUpdateInternalPerson() { InternalPersonDto ipDto = MockDataHelper.mockInternalPersonDto(); TblInternalPerson ipTbl = MockDataHelper.mockInternalPerson(); when(internalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(ipTbl)); @@ -122,13 +127,13 @@ assertEquals(ipTbl.getTitle(), savedDto.getTitle()); assertEquals(ipTbl.getUserRef(), savedDto.getUserRef()); assertEquals(ipTbl.getDepartment(), savedDto.getDepartment()); - assertEquals(ipTbl.getUid(), savedDto.getUid()); + assertEquals(ipTbl.getUidIdent(), savedDto.getUid()); assertEquals(ipTbl.getRefPersonType().getUuid(), savedDto.getPersonTypeUuid()); assertEquals(ipTbl.getSalutation().getUuid(), savedDto.getSalutationUuid()); } @Test - public void shouldNotUpdateInternalPerson_Exception1() { + void shouldNotUpdateInternalPerson_Exception1() { InternalPersonDto ipDto = MockDataHelper.mockInternalPersonDto(); TblInternalPerson ipTbl = MockDataHelper.mockInternalPerson(); when(internalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.empty()); @@ -147,7 +152,7 @@ } @Test - public void shouldNotUpdateInternalPerson_Exception2() { + void shouldNotUpdateInternalPerson_Exception2() { InternalPersonDto epDto = MockDataHelper.mockInternalPersonDto(); TblInternalPerson epTbl = MockDataHelper.mockInternalPerson(); when(internalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(epTbl)); @@ -165,7 +170,7 @@ assertThrows( NotFoundException.class, () -> internalPersonService.updateInternalPerson(epDto)); } @Test - public void shouldNotUpdateInternalPerson_Exception3() { + void shouldNotUpdateInternalPerson_Exception3() { InternalPersonDto ipDto = MockDataHelper.mockInternalPersonDto(); TblInternalPerson ipTbl = MockDataHelper.mockInternalPerson(); when(internalPersonRepository.findByTblContactUuid(any(UUID.class))).thenReturn(Optional.of(ipTbl)); @@ -184,7 +189,7 @@ } @Test - public void shouldInsertInternalPerson() { + void shouldInsertInternalPerson() { InternalPersonDto ipDto = MockDataHelper.mockInternalPersonDto(); ipDto.setContactUuid(null); RefSalutation refSalutation = MockDataHelper.mockRefSalutation();
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/LdapServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/LdapServiceTest.java index 1e03724..8ddd9eb 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/LdapServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/LdapServiceTest.java
@@ -33,6 +33,7 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.query.LdapQuery; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.ArrayList; @@ -45,8 +46,8 @@ @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class LdapServiceTest { +@ActiveProfiles("test") +class LdapServiceTest { private static final long MAIL_ID = 1L; private static final long TEL_ID = 2L; @@ -70,14 +71,14 @@ private LdapTemplate ldapTemplate; @Test - public void shouldSynchronizeLDAPRunThrou1() { + void shouldSynchronizeLDAPRunThrou1() { when(internalPersonRepository.saveAll(any( List.class ))).thenReturn(Lists.emptyList()); List<TblInternalPerson> internalPeople = MockDataHelper.mockTblInternalPersonPage().getContent(); - when( internalPersonRepository.findByUidNotNull() ).thenReturn(internalPeople); + when( internalPersonRepository.findByUidIdentNotNull() ).thenReturn(internalPeople); List<LdapUser> ldapUserList = new ArrayList<>(1); LdapUser ldapUser = MockDataHelper.mockLdapUser(); - ldapUser.setUid(internalPeople.get(0).getUid()); + ldapUser.setUid(internalPeople.get(0).getUidIdent()); ldapUserList.add( ldapUser ); // users are found when( ldapTemplate.search(any(LdapQuery.class), any(LdapUserAttributesMapper.class))).thenReturn( ldapUserList ); @@ -101,11 +102,11 @@ } @Test - public void shouldSynchronizeLDAPRunThrou2() { + void shouldSynchronizeLDAPRunThrou2() { when(internalPersonRepository.saveAll(any( List.class ))).thenReturn(Lists.emptyList()); List<TblInternalPerson> internalPeople = MockDataHelper.mockTblInternalPersonPage().getContent(); - when( internalPersonRepository.findByUidNotNull() ).thenReturn(internalPeople); + when( internalPersonRepository.findByUidIdentNotNull() ).thenReturn(internalPeople); // users are not found when( ldapTemplate.search(any(LdapQuery.class), any(LdapUserAttributesMapper.class))).thenReturn( Lists.emptyList() ); @@ -123,14 +124,14 @@ } @Test - public void shouldFindExistingAndNotExistingLdapUsers1() throws Exception { + void shouldFindExistingAndNotExistingLdapUsers1() throws Exception { List<TblInternalPerson> internalPeople = MockDataHelper.mockTblInternalPersonPage().getContent(); List<LdapUser> ldapUsers = new ArrayList<>(); List<TblInternalPerson> allNotExistingLdapUsers = new ArrayList<>(); List<LdapUser> ldapUserList = new ArrayList<>(1); LdapUser ldapUser = MockDataHelper.mockLdapUser(); - ldapUser.setUid(internalPeople.get(0).getUid()); + ldapUser.setUid(internalPeople.get(0).getUidIdent()); ldapUserList.add( ldapUser ); // users are always found when( ldapTemplate.search(any(LdapQuery.class), any(LdapUserAttributesMapper.class))).thenReturn( ldapUserList ); @@ -144,7 +145,7 @@ } @Test - public void shouldFindExistingAndNotExistingLdapUsers2() throws Exception { + void shouldFindExistingAndNotExistingLdapUsers2() throws Exception { List<TblInternalPerson> internalPeople = MockDataHelper.mockTblInternalPersonPage().getContent(); List<LdapUser> ldapUsers = new ArrayList<>(); List<TblInternalPerson> allNotExistingLdapUsers = new ArrayList<>(); @@ -160,14 +161,14 @@ @Test - public void shouldFindExistingAndNotExistingLdapUsers3() throws Exception { + void shouldFindExistingAndNotExistingLdapUsers3() throws Exception { List<TblInternalPerson> internalPeople = MockDataHelper.mockTblInternalPersonPage().getContent(); List<LdapUser> ldapUsers = new ArrayList<>(); List<TblInternalPerson> allNotExistingLdapUsers = new ArrayList<>(); List<LdapUser> ldapUserList = new ArrayList<>(1); LdapUser ldapUser = MockDataHelper.mockLdapUser(); - ldapUser.setUid(internalPeople.get(0).getUid()); + ldapUser.setUid(internalPeople.get(0).getUidIdent()); ldapUserList.add( ldapUser ); ldapUserList.add( new LdapUser()); // too much users are found
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/PersonTypeServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/PersonTypeServiceTest.java index d6484a1..d0e07ff 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/PersonTypeServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/PersonTypeServiceTest.java
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import java.util.List; @@ -40,8 +41,8 @@ @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class PersonTypeServiceTest { +@ActiveProfiles("test") +class PersonTypeServiceTest { @Qualifier("myPersonTypeService") @Autowired private PersonTypeService personTypeService; @@ -50,19 +51,19 @@ private PersonTypeRepository personTypeRepository; @Test - public void shouldFindAllPersonTypesProperly() { + void shouldFindAllPersonTypesProperly() { List<RefPersonType> rs = MockDataHelper.mockRefPersonTypes(); when(personTypeRepository.findAll()).thenReturn(rs); List<PersonTypeDto> retVals = personTypeService.findAllPersonTypes(); assertEquals(rs.size(), retVals.size()); - assertEquals(rs.size(), 2); + assertEquals(2, rs.size()); assertEquals(rs.get(1).getUuid(), retVals.get(1).getUuid()); } @Test - public void shouldReturnPersonTypeByUuid() { + void shouldReturnPersonTypeByUuid() { RefPersonType refPersonType = MockDataHelper.mockRefPersonType(); refPersonType.setType("Testtyp"); @@ -74,7 +75,7 @@ } @Test - public void shouldInsertPersonType(){ + void shouldInsertPersonType(){ RefPersonType refPersonType = MockDataHelper.mockRefPersonType(); refPersonType.setUuid(UUID.fromString("1468275e-200b-11ea-978f-2e728ce88125")); @@ -92,7 +93,7 @@ } @Test - public void shouldUpdatePersonType() { + void shouldUpdatePersonType() { RefPersonType personType = MockDataHelper.mockRefPersonType(); personType.setType("Kein schöner Mensch"); @@ -110,7 +111,7 @@ @Test - public void shouldDeletePersonType() { + void shouldDeletePersonType() { RefPersonType personType = MockDataHelper.mockRefPersonType();
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/SalutationServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/SalutationServiceTest.java index 99f20d1..52c2257 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/SalutationServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/SalutationServiceTest.java
@@ -25,8 +25,8 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; -import org.springframework.util.Assert; import java.util.List; import java.util.Optional; @@ -34,7 +34,6 @@ import static org.hibernate.validator.internal.util.Contracts.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.times; @@ -42,8 +41,8 @@ @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class SalutationServiceTest { +@ActiveProfiles("test") +class SalutationServiceTest { @Qualifier("mySalutationService") @Autowired private SalutationService salutationService; @@ -52,19 +51,19 @@ private SalutationRepository salutationRepository; @Test - public void shouldFindAllSalutationsProperly() { + void shouldFindAllSalutationsProperly() { List<RefSalutation> rs = MockDataHelper.mockRefSalutations(); when(salutationRepository.findAll()).thenReturn(rs); List<SalutationDto> retVals = salutationService.findAllSalutations(); assertEquals(rs.size(), retVals.size()); - assertEquals(rs.size(), 2); + assertEquals(2, rs.size()); assertEquals(rs.get(1).getUuid(), retVals.get(1).getUuid()); } @Test - public void shouldReturnSalutationByUuid() { + void shouldReturnSalutationByUuid() { RefSalutation refSalutation = MockDataHelper.mockRefSalutation(); refSalutation.setType("Testtyp"); @@ -76,7 +75,7 @@ } @Test - public void shouldInsertSalutation(){ + void shouldInsertSalutation(){ RefSalutation refSalutation = MockDataHelper.mockRefSalutation(); refSalutation.setUuid(UUID.fromString("1468275e-200b-11ea-978f-2e728ce88125")); @@ -94,7 +93,7 @@ } @Test - public void shouldUpdateSalutation() { + void shouldUpdateSalutation() { RefSalutation salutation = MockDataHelper.mockRefSalutation(); salutation.setType("Moin Frau"); @@ -112,7 +111,7 @@ @Test - public void shouldDeleteSalutation() { + void shouldDeleteSalutation() { RefSalutation salutation = MockDataHelper.mockRefSalutation();
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/VersionServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/VersionServiceTest.java index 271bc11..f92e798 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/VersionServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/VersionServiceTest.java
@@ -21,12 +21,12 @@ import org.eclipse.openk.contactbasedata.support.MockDataHelper; import org.eclipse.openk.contactbasedata.viewmodel.VersionDto; import org.junit.jupiter.api.Test; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.context.ContextConfiguration; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; import java.util.Optional; @@ -34,11 +34,11 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; -//@RunWith(SpringRunner.class) + @DataJpaTest @ContextConfiguration(classes = {TestConfiguration.class}) - -public class VersionServiceTest { +@ActiveProfiles("test") +class VersionServiceTest { @Qualifier("myVersionService") @Autowired private VersionService versionService; @@ -47,7 +47,7 @@ private VersionRepository versionRepository; @Test - public void shouldGetVersionProperly() { + void shouldGetVersionProperly() { Version mockVersion = MockDataHelper.mockVersion(); when(versionRepository.findById(any(Long.class))).thenReturn(Optional.of(mockVersion)); VersionDto versionDto = versionService.getVersion(); @@ -56,7 +56,7 @@ } @Test - public void shouldGetVersionCorrectlyInErrorCase() { + void shouldGetVersionCorrectlyInErrorCase() { when(versionRepository.findById(any(Long.class))).thenReturn(Optional.empty()); VersionDto versionDto = versionService.getVersion(); assertEquals(Constants.DB_VERSION_NOT_PRESENT, versionDto.getDbVersion() );
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/util/LdapUserAttributesMapperTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/util/LdapUserAttributesMapperTest.java index 7f31a76..117fc86 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/util/LdapUserAttributesMapperTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/util/LdapUserAttributesMapperTest.java
@@ -18,14 +18,14 @@ import static org.mockito.Mockito.when; @SpringBootTest(classes = ContactBaseDataApplication.class) -@ActiveProfiles("test") // Todo: Find a better way to configure the tests -public class LdapUserAttributesMapperTest { +@ActiveProfiles("test") +class LdapUserAttributesMapperTest { @Autowired LdapUserAttributesMapper ldapUserAttributesMapper; @Test - public void shouldMapFromAttributesCorrectly() throws NamingException { + void shouldMapFromAttributesCorrectly() throws NamingException { Attributes attributes = Mockito.mock(Attributes.class); String[] fields = {"uid", "cn", "sn", "givenname", "title", "mail", "department", "phone"}; @@ -48,7 +48,7 @@ } @Test - public void shouldMapFromAttributesEmpty() throws NamingException { + void shouldMapFromAttributesEmpty() throws NamingException { Attributes attributes = Mockito.mock(Attributes.class); String[] fields = {"uid", "cn", "sn", "givenname", "title", "mail", "department", "phone"};
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/support/MockDataHelper.java b/src/test/java/org/eclipse/openk/contactbasedata/support/MockDataHelper.java index 8ce842f..a5a7e92 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/support/MockDataHelper.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/support/MockDataHelper.java
@@ -15,8 +15,35 @@ package org.eclipse.openk.contactbasedata.support; import org.eclipse.openk.contactbasedata.constants.Constants; -import org.eclipse.openk.contactbasedata.model.*; -import org.eclipse.openk.contactbasedata.viewmodel.*; +import org.eclipse.openk.contactbasedata.model.KeyCloakUser; +import org.eclipse.openk.contactbasedata.model.RefAddressType; +import org.eclipse.openk.contactbasedata.model.RefCommunicationType; +import org.eclipse.openk.contactbasedata.model.RefPersonType; +import org.eclipse.openk.contactbasedata.model.RefSalutation; +import org.eclipse.openk.contactbasedata.model.TblAddress; +import org.eclipse.openk.contactbasedata.model.TblAssignmentModulContact; +import org.eclipse.openk.contactbasedata.model.TblCommunication; +import org.eclipse.openk.contactbasedata.model.TblCompany; +import org.eclipse.openk.contactbasedata.model.TblContact; +import org.eclipse.openk.contactbasedata.model.TblContactPerson; +import org.eclipse.openk.contactbasedata.model.TblExternalPerson; +import org.eclipse.openk.contactbasedata.model.TblInternalPerson; +import org.eclipse.openk.contactbasedata.model.Version; +import org.eclipse.openk.contactbasedata.model.VwDetailedContact; +import org.eclipse.openk.contactbasedata.viewmodel.AddressDto; +import org.eclipse.openk.contactbasedata.viewmodel.AddressTypeDto; +import org.eclipse.openk.contactbasedata.viewmodel.AssignmentModulContactDto; +import org.eclipse.openk.contactbasedata.viewmodel.CommunicationDto; +import org.eclipse.openk.contactbasedata.viewmodel.CommunicationTypeDto; +import org.eclipse.openk.contactbasedata.viewmodel.CompanyDto; +import org.eclipse.openk.contactbasedata.viewmodel.ContactDto; +import org.eclipse.openk.contactbasedata.viewmodel.ContactPersonDto; +import org.eclipse.openk.contactbasedata.viewmodel.ExternalPersonDto; +import org.eclipse.openk.contactbasedata.viewmodel.InternalPersonDto; +import org.eclipse.openk.contactbasedata.viewmodel.LdapUser; +import org.eclipse.openk.contactbasedata.viewmodel.PersonTypeDto; +import org.eclipse.openk.contactbasedata.viewmodel.SalutationDto; +import org.eclipse.openk.contactbasedata.viewmodel.VersionDto; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; @@ -24,7 +51,11 @@ import javax.naming.NamingException; import javax.naming.directory.Attribute; import java.sql.Date; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.UUID; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -391,7 +422,7 @@ i.setLastName("Weinbrenner"); i.setTitle("Freiherr"); i.setDepartment("Forschung"); - i.setUid("111-777"); + i.setUidIdent("111-777"); i.setUserRef("WWEINB"); i.setRefPersonType(mockRefPersonType()); i.setSalutation(mockRefSalutation()); @@ -447,7 +478,7 @@ ip2.setLastName("Alter"); ip2.setTitle("Dr."); ip2.setDepartment("Geschäftsführung"); - ip2.setUid("333-999"); + ip2.setUidIdent("333-999"); ip2.setUserRef("FALTER"); ip2.getContact().setNote("Gründer");
diff --git a/src/test/resouces/application.yml b/src/test/resouces/application.yml index c95f067..266525d 100644 --- a/src/test/resouces/application.yml +++ b/src/test/resouces/application.yml
@@ -14,12 +14,12 @@ datasource: url: jdbc:h2:mem:test;DB_CLOSE_DELAY=-1 -jpa: - hibernate: - ddl-auto: create - show-sql: true -flyway: - enabled: false + jpa: + hibernate: + ddl-auto: create + show-sql: true + flyway: + enabled: false jwt: tokenHeader: accessToken