From e08a5ca5c9edcb15a72235bdfd935ff3a3ced8d2 Mon Sep 17 00:00:00 2001 From: Ruslan Kashapov Date: Wed, 13 Jan 2021 16:45:29 +0200 Subject: Rename entity artifacts, remove obsolete entities Issue-ID: CPS-162 Change-Id: I10604e12a01f22930278118830eed53f5a2b159c Signed-off-by: Ruslan Kashapov --- .../org/onap/cps/spi/entities/AnchorEntity.java | 4 +- .../java/org/onap/cps/spi/entities/Dataspace.java | 65 ---------------- .../org/onap/cps/spi/entities/DataspaceEntity.java | 65 ++++++++++++++++ .../java/org/onap/cps/spi/entities/Fragment.java | 82 -------------------- .../org/onap/cps/spi/entities/FragmentEntity.java | 82 ++++++++++++++++++++ .../org/onap/cps/spi/entities/JsonDataEntity.java | 54 -------------- .../java/org/onap/cps/spi/entities/Module.java | 87 ---------------------- .../java/org/onap/cps/spi/entities/SchemaSet.java | 71 ------------------ .../org/onap/cps/spi/entities/SchemaSetEntity.java | 71 ++++++++++++++++++ .../org/onap/cps/spi/entities/YangResource.java | 67 ----------------- .../onap/cps/spi/entities/YangResourceEntity.java | 67 +++++++++++++++++ .../spi/impl/CpsAdminPersistenceServiceImpl.java | 19 ++--- .../spi/impl/CpsModulePersistenceServiceImpl.java | 62 +++++++-------- .../onap/cps/spi/repository/AnchorRepository.java | 7 +- .../cps/spi/repository/DataspaceRepository.java | 9 +-- .../cps/spi/repository/FragmentRepository.java | 4 +- .../onap/cps/spi/repository/ModuleRepository.java | 55 -------------- .../cps/spi/repository/SchemaSetRepository.java | 22 +++--- .../cps/spi/repository/YangResourceRepository.java | 6 +- .../spi/impl/CpsAdminPersistenceServiceTest.java | 14 ++-- .../spi/impl/CpsModulePersistenceServiceTest.java | 36 ++++----- 21 files changed, 379 insertions(+), 570 deletions(-) delete mode 100644 cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java create mode 100644 cps-ri/src/main/java/org/onap/cps/spi/entities/DataspaceEntity.java delete mode 100755 cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java create mode 100755 cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java delete mode 100644 cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java delete mode 100755 cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java delete mode 100644 cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSet.java create mode 100644 cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSetEntity.java delete mode 100644 cps-ri/src/main/java/org/onap/cps/spi/entities/YangResource.java create mode 100644 cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java delete mode 100755 cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java (limited to 'cps-ri') diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java index e7e9c971d..b89342827 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/AnchorEntity.java @@ -61,10 +61,10 @@ public class AnchorEntity implements Serializable { @NotNull @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "schema_set_id") - private SchemaSet schemaSet; + private SchemaSetEntity schemaSet; @NotNull @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "dataspace_id") - private Dataspace dataspace; + private DataspaceEntity dataspace; } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java deleted file mode 100644 index 9f127f432..000000000 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.spi.entities; - -import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - - -/** - * Entity to store a dataspace. - */ -@Getter -@Setter -@Entity -@AllArgsConstructor -@NoArgsConstructor -@Table(name = "dataspace") -public class Dataspace implements Serializable { - - private static final long serialVersionUID = 8395254649813051882L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @NotNull - @Column(columnDefinition = "text") - private String name; - - /** - * Initialize a Dataspace . - * - * @param name the Dataspace name. - */ - public Dataspace(final String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/DataspaceEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/DataspaceEntity.java new file mode 100644 index 000000000..45b41dbe8 --- /dev/null +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/DataspaceEntity.java @@ -0,0 +1,65 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.spi.entities; + +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + + +/** + * Entity to store a dataspace. + */ +@Getter +@Setter +@Entity +@AllArgsConstructor +@NoArgsConstructor +@Table(name = "dataspace") +public class DataspaceEntity implements Serializable { + + private static final long serialVersionUID = 8395254649813051882L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @NotNull + @Column(columnDefinition = "text") + private String name; + + /** + * Initialize a Dataspace . + * + * @param name the Dataspace name. + */ + public DataspaceEntity(final String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java deleted file mode 100755 index 053a22321..000000000 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Fragment.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.spi.entities; - -import com.vladmihalcea.hibernate.type.json.JsonBinaryType; -import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -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.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.annotations.Type; -import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; - -/** - * Entity to store a fragment. - */ -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -@Entity -@TypeDefs({@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)}) -public class Fragment implements Serializable { - - private static final long serialVersionUID = 7737669789097119667L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @Column(columnDefinition = "text") - private String xpath; - - @Type(type = "jsonb") - @Column(columnDefinition = "jsonb") - private String attributes; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "dataspace_id") - private Dataspace dataspace; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "anchor_id") - private AnchorEntity anchor; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "parent_id") - private Fragment parentFragment; -} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java new file mode 100755 index 000000000..d1557489c --- /dev/null +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/FragmentEntity.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.spi.entities; + +import com.vladmihalcea.hibernate.type.json.JsonBinaryType; +import java.io.Serializable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +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.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; + +/** + * Entity to store a fragment. + */ +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +@Builder +@Entity +@TypeDefs({@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)}) +public class FragmentEntity implements Serializable { + + private static final long serialVersionUID = 7737669789097119667L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @Column(columnDefinition = "text") + private String xpath; + + @Type(type = "jsonb") + @Column(columnDefinition = "jsonb") + private String attributes; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "dataspace_id") + private DataspaceEntity dataspace; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "anchor_id") + private AnchorEntity anchor; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_id") + private FragmentEntity parentFragment; +} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java deleted file mode 100644 index bd147bf73..000000000 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.spi.entities; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * Entity to store a JSON data structure. - */ -@Getter -@Setter -@Entity -@AllArgsConstructor -@NoArgsConstructor -@Table(name = "JsonData") -public class JsonDataEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column - private String jsonStructure; - - public JsonDataEntity(final String jsonStructure) { - this.jsonStructure = jsonStructure; - } -} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java deleted file mode 100755 index 7043c7395..000000000 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation - * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.spi.entities; - -import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * Entity to store a yang module. - */ -@Getter -@Setter -@Entity -@AllArgsConstructor -@NoArgsConstructor -@Table(name = "module") -public class Module implements Serializable { - - private static final long serialVersionUID = -748666970938314895L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @NotNull - @Column - private String moduleContent; - - @NotNull - @Column - private String revision; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "dataspace_id", referencedColumnName = "ID") - private Dataspace dataspace; - - @NotNull - @Column - private String namespace; - - /** - * Initialize a module entity. - * - * @param namespace the module namespace. - * @param moduleContent the module content. - * @param revision the revision number of the module. - * @param dataspace the dataspace related to the module. - */ - public Module(final String namespace, final String moduleContent, final String revision, - final Dataspace dataspace) { - this.namespace = namespace; - this.moduleContent = moduleContent; - this.revision = revision; - this.dataspace = dataspace; - } -} \ No newline at end of file diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSet.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSet.java deleted file mode 100644 index fe67a6089..000000000 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSet.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Pantheon.tech - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.spi.entities; - -import java.io.Serializable; -import java.util.Set; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * Entity to store a Schema Set. - */ -@Getter -@Setter -@NoArgsConstructor -@Entity -@Table(name = "schema_set") -public class SchemaSet implements Serializable { - - private static final long serialVersionUID = 6665056955069047269L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @NotNull - @Column - private String name; - - @NotNull - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "dataspace_id", referencedColumnName = "ID") - private Dataspace dataspace; - - @NotNull - @ManyToMany(fetch = FetchType.LAZY) - @JoinTable(name = "schema_set_yang_resources", - joinColumns = @JoinColumn(name = "schema_set_id"), - inverseJoinColumns = @JoinColumn(name = "yang_resource_id")) - private Set yangResources; -} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSetEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSetEntity.java new file mode 100644 index 000000000..9926dfad1 --- /dev/null +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/SchemaSetEntity.java @@ -0,0 +1,71 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Pantheon.tech + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.spi.entities; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * Entity to store a Schema Set. + */ +@Getter +@Setter +@NoArgsConstructor +@Entity +@Table(name = "schema_set") +public class SchemaSetEntity implements Serializable { + + private static final long serialVersionUID = 6665056955069047269L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @NotNull + @Column + private String name; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "dataspace_id", referencedColumnName = "ID") + private DataspaceEntity dataspace; + + @NotNull + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "schema_set_yang_resources", + joinColumns = @JoinColumn(name = "schema_set_id"), + inverseJoinColumns = @JoinColumn(name = "yang_resource_id")) + private Set yangResources; +} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResource.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResource.java deleted file mode 100644 index b8a58d098..000000000 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResource.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Pantheon.tech - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.spi.entities; - -import java.io.Serializable; -import java.util.Set; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * Entity to store a Yang files. - */ -@Getter -@Setter -@NoArgsConstructor -@Entity -@Table(name = "yang_resource") -public class YangResource implements Serializable { - - private static final long serialVersionUID = -4496883162142106774L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @NotNull - @Column - private String checksum; - - @NotNull - @Column - private String name; - - @NotNull - @Column - private String content; - - @ManyToMany(mappedBy = "yangResources") - private Set moduleSets; - -} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java new file mode 100644 index 000000000..4763d68f6 --- /dev/null +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/YangResourceEntity.java @@ -0,0 +1,67 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Pantheon.tech + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.cps.spi.entities; + +import java.io.Serializable; +import java.util.Set; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * Entity to store a Yang files. + */ +@Getter +@Setter +@NoArgsConstructor +@Entity +@Table(name = "yang_resource") +public class YangResourceEntity implements Serializable { + + private static final long serialVersionUID = -4496883162142106774L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @Column + private String checksum; + + @NotNull + @Column + private String name; + + @NotNull + @Column + private String content; + + @ManyToMany(mappedBy = "yangResources") + private Set schemaSets; + +} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java index fdb446c84..dfe3ecc11 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceImpl.java @@ -25,8 +25,8 @@ import java.util.Collection; import java.util.stream.Collectors; import org.onap.cps.spi.CpsAdminPersistenceService; import org.onap.cps.spi.entities.AnchorEntity; -import org.onap.cps.spi.entities.Dataspace; -import org.onap.cps.spi.entities.SchemaSet; +import org.onap.cps.spi.entities.DataspaceEntity; +import org.onap.cps.spi.entities.SchemaSetEntity; import org.onap.cps.spi.exceptions.AnchorAlreadyDefinedException; import org.onap.cps.spi.exceptions.DataspaceAlreadyDefinedException; import org.onap.cps.spi.model.Anchor; @@ -52,7 +52,7 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic @Override public void createDataspace(final String dataspaceName) { try { - dataspaceRepository.save(new Dataspace(dataspaceName)); + dataspaceRepository.save(new DataspaceEntity(dataspaceName)); } catch (final DataIntegrityViolationException e) { throw new DataspaceAlreadyDefinedException(dataspaceName, e); } @@ -60,12 +60,13 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic @Override public void createAnchor(final String dataspaceName, final String schemaSetName, final String anchorName) { - final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName); - final SchemaSet schemaSet = schemaSetRepository.getByDataspaceAndName(dataspace, schemaSetName); + final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); + final SchemaSetEntity schemaSetEntity = + schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName); final AnchorEntity anchorEntity = AnchorEntity.builder() .name(anchorName) - .dataspace(dataspace) - .schemaSet(schemaSet) + .dataspace(dataspaceEntity) + .schemaSet(schemaSetEntity) .build(); try { anchorRepository.save(anchorEntity); @@ -76,8 +77,8 @@ public class CpsAdminPersistenceServiceImpl implements CpsAdminPersistenceServic @Override public Collection getAnchors(final String dataspaceName) { - final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName); - final Collection anchorEntities = anchorRepository.findAllByDataspace(dataspace); + final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); + final Collection anchorEntities = anchorRepository.findAllByDataspace(dataspaceEntity); return anchorEntities.stream().map(CpsAdminPersistenceServiceImpl::toAnchor).collect(Collectors.toList()); } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java index 08329309c..cbc945da6 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceImpl.java @@ -29,9 +29,9 @@ import java.util.Set; import java.util.stream.Collectors; import javax.transaction.Transactional; import org.onap.cps.spi.CpsModulePersistenceService; -import org.onap.cps.spi.entities.Dataspace; -import org.onap.cps.spi.entities.SchemaSet; -import org.onap.cps.spi.entities.YangResource; +import org.onap.cps.spi.entities.DataspaceEntity; +import org.onap.cps.spi.entities.SchemaSetEntity; +import org.onap.cps.spi.entities.YangResourceEntity; import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException; import org.onap.cps.spi.repository.DataspaceRepository; import org.onap.cps.spi.repository.SchemaSetRepository; @@ -58,53 +58,55 @@ public class CpsModulePersistenceServiceImpl implements CpsModulePersistenceServ public void storeSchemaSet(final String dataspaceName, final String schemaSetName, final Map yangResourcesNameToContentMap) { - final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName); - final Set yangResources = synchronizeYangResources(yangResourcesNameToContentMap); - final SchemaSet schemaSet = new SchemaSet(); - schemaSet.setName(schemaSetName); - schemaSet.setDataspace(dataspace); - schemaSet.setYangResources(yangResources); + final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); + final Set yangResourceEntities = synchronizeYangResources(yangResourcesNameToContentMap); + final SchemaSetEntity schemaSetEntity = new SchemaSetEntity(); + schemaSetEntity.setName(schemaSetName); + schemaSetEntity.setDataspace(dataspaceEntity); + schemaSetEntity.setYangResources(yangResourceEntities); try { - schemaSetRepository.save(schemaSet); + schemaSetRepository.save(schemaSetEntity); } catch (final DataIntegrityViolationException e) { throw new SchemaSetAlreadyDefinedException(dataspaceName, schemaSetName, e); } } - private Set synchronizeYangResources(final Map yangResourcesNameToContentMap) { - final Map checksumToEntityMap = yangResourcesNameToContentMap.entrySet().stream() + private Set synchronizeYangResources(final Map yangResourcesNameToContentMap) { + final Map checksumToEntityMap = yangResourcesNameToContentMap.entrySet().stream() .map(entry -> { - final YangResource yangResource = new YangResource(); - yangResource.setName(entry.getKey()); - yangResource.setContent(entry.getValue()); - yangResource.setChecksum(DigestUtils.md5DigestAsHex(entry.getValue().getBytes(StandardCharsets.UTF_8))); - return yangResource; + final String checksum = DigestUtils.md5DigestAsHex(entry.getValue().getBytes(StandardCharsets.UTF_8)); + final YangResourceEntity yangResourceEntity = new YangResourceEntity(); + yangResourceEntity.setName(entry.getKey()); + yangResourceEntity.setContent(entry.getValue()); + yangResourceEntity.setChecksum(checksum); + return yangResourceEntity; }) .collect(Collectors.toMap( - YangResource::getChecksum, + YangResourceEntity::getChecksum, entity -> entity )); - final List existingYangResources = + final List existingYangResourceEntities = yangResourceRepository.findAllByChecksumIn(checksumToEntityMap.keySet()); - existingYangResources.forEach(yangFile -> checksumToEntityMap.remove(yangFile.getChecksum())); + existingYangResourceEntities.forEach(yangFile -> checksumToEntityMap.remove(yangFile.getChecksum())); - final Collection newYangResources = checksumToEntityMap.values(); - if (!newYangResources.isEmpty()) { - yangResourceRepository.saveAll(newYangResources); + final Collection newYangResourceEntities = checksumToEntityMap.values(); + if (!newYangResourceEntities.isEmpty()) { + yangResourceRepository.saveAll(newYangResourceEntities); } - return ImmutableSet.builder() - .addAll(existingYangResources) - .addAll(newYangResources) + return ImmutableSet.builder() + .addAll(existingYangResourceEntities) + .addAll(newYangResourceEntities) .build(); } @Override public Map getYangSchemaResources(final String dataspaceName, final String schemaSetName) { - final Dataspace dataspace = dataspaceRepository.getByName(dataspaceName); - final SchemaSet schemaSet = schemaSetRepository.getByDataspaceAndName(dataspace, schemaSetName); - return schemaSet.getYangResources().stream().collect( - Collectors.toMap(YangResource::getName, YangResource::getContent)); + final DataspaceEntity dataspaceEntity = dataspaceRepository.getByName(dataspaceName); + final SchemaSetEntity schemaSetEntity = + schemaSetRepository.getByDataspaceAndName(dataspaceEntity, schemaSetName); + return schemaSetEntity.getYangResources().stream().collect( + Collectors.toMap(YangResourceEntity::getName, YangResourceEntity::getContent)); } } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java index df665f931..318b4daa6 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/AnchorRepository.java @@ -23,11 +23,12 @@ import java.util.Collection; import java.util.Optional; import javax.validation.constraints.NotNull; import org.onap.cps.spi.entities.AnchorEntity; -import org.onap.cps.spi.entities.Dataspace; +import org.onap.cps.spi.entities.DataspaceEntity; import org.springframework.data.jpa.repository.JpaRepository; public interface AnchorRepository extends JpaRepository { - Optional findByDataspaceAndName(@NotNull Dataspace dataspace, @NotNull String name); - Collection findAllByDataspace(@NotNull Dataspace dataspace); + Optional findByDataspaceAndName(@NotNull DataspaceEntity dataspaceEntity, @NotNull String name); + + Collection findAllByDataspace(@NotNull DataspaceEntity dataspaceEntity); } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java index ce231c9c5..10c6541d0 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java @@ -21,16 +21,15 @@ package org.onap.cps.spi.repository; import java.util.Optional; import javax.validation.constraints.NotNull; -import org.onap.cps.spi.entities.Dataspace; +import org.onap.cps.spi.entities.DataspaceEntity; import org.onap.cps.spi.exceptions.DataspaceNotFoundException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface DataspaceRepository extends JpaRepository { - Boolean existsByName(String name); //Checks if there are any records by name() +public interface DataspaceRepository extends JpaRepository { - Optional findByName(@NotNull String name); + Optional findByName(@NotNull String name); /** * Get a dataspace by name. @@ -39,7 +38,7 @@ public interface DataspaceRepository extends JpaRepository { * @param name the name of the dataspace * @return the Dataspace found */ - default Dataspace getByName(@NotNull final String name) { + default DataspaceEntity getByName(@NotNull final String name) { return findByName(name).orElseThrow(() -> new DataspaceNotFoundException(name)); } } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java index 4521d091d..28585f876 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java @@ -21,11 +21,11 @@ package org.onap.cps.spi.repository; -import org.onap.cps.spi.entities.Fragment; +import org.onap.cps.spi.entities.FragmentEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface FragmentRepository extends JpaRepository { +public interface FragmentRepository extends JpaRepository { } \ No newline at end of file diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java deleted file mode 100755 index cab7e1930..000000000 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/ModuleRepository.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.spi.repository; - - -import java.util.Optional; -import javax.validation.constraints.NotNull; -import org.onap.cps.spi.entities.Dataspace; -import org.onap.cps.spi.entities.Module; -import org.onap.cps.spi.exceptions.NotFoundInDataspaceException; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ModuleRepository extends JpaRepository { - - Optional findByDataspaceAndNamespaceAndRevision(@NotNull Dataspace dataspace, - @NotNull String namespace, - @NotNull String revision); - - /** - * This method gets a Module by dataspace, namespace and revision. - * - * @param dataspace the dataspace - * @param namespace the namespace - * @param revision the revision - * @return the Module - * @throws NotFoundInDataspaceException if Module not found - */ - default Module getByDataspaceAndNamespaceAndRevision(@NotNull final Dataspace dataspace, - @NotNull final String namespace, - @NotNull final String revision) { - return findByDataspaceAndNamespaceAndRevision(dataspace, namespace, revision) - .orElseThrow(() -> new NotFoundInDataspaceException("Validation Error", String.format( - "Module with dataspace %s, revision %s does not exist in namespace %s.", - dataspace.getName(), revision, namespace))); - } -} diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java index 9b9d70625..7b56f9323 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/SchemaSetRepository.java @@ -22,29 +22,31 @@ package org.onap.cps.spi.repository; import java.util.List; import java.util.Optional; import javax.validation.constraints.NotNull; -import org.onap.cps.spi.entities.Dataspace; -import org.onap.cps.spi.entities.SchemaSet; +import org.onap.cps.spi.entities.DataspaceEntity; +import org.onap.cps.spi.entities.SchemaSetEntity; import org.onap.cps.spi.exceptions.SchemaSetNotFoundException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface SchemaSetRepository extends JpaRepository { +public interface SchemaSetRepository extends JpaRepository { - List findAllByDataspace(@NotNull Dataspace dataspace); + List findAllByDataspace(@NotNull DataspaceEntity dataspaceEntity); - Optional findByDataspaceAndName(@NotNull Dataspace dataspace, @NotNull String schemaSetName); + Optional findByDataspaceAndName(@NotNull DataspaceEntity dataspaceEntity, + @NotNull String schemaSetName); /** * Gets a schema set by dataspace and schema set name. * - * @param dataspace dataspace entity - * @param schemaSetName schema set name + * @param dataspaceEntity dataspace entity + * @param schemaSetName schema set name * @return schema set entity * @throws SchemaSetNotFoundException if SchemaSet not found */ - default SchemaSet getByDataspaceAndName(@NotNull final Dataspace dataspace, @NotNull final String schemaSetName) { - return findByDataspaceAndName(dataspace, schemaSetName) - .orElseThrow(() -> new SchemaSetNotFoundException(dataspace.getName(), schemaSetName)); + default SchemaSetEntity getByDataspaceAndName(@NotNull final DataspaceEntity dataspaceEntity, + @NotNull final String schemaSetName) { + return findByDataspaceAndName(dataspaceEntity, schemaSetName) + .orElseThrow(() -> new SchemaSetNotFoundException(dataspaceEntity.getName(), schemaSetName)); } } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java index 47d3ea32c..8e57f633f 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/YangResourceRepository.java @@ -22,13 +22,13 @@ package org.onap.cps.spi.repository; import java.util.List; import java.util.Set; import javax.validation.constraints.NotNull; -import org.onap.cps.spi.entities.YangResource; +import org.onap.cps.spi.entities.YangResourceEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface YangResourceRepository extends JpaRepository { +public interface YangResourceRepository extends JpaRepository { - List findAllByChecksumIn(@NotNull Set checksum); + List findAllByChecksumIn(@NotNull Set checksum); } diff --git a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java index e5aac1eea..02487078d 100644 --- a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java +++ b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsAdminPersistenceServiceTest.java @@ -30,7 +30,7 @@ import org.junit.runner.RunWith; import org.onap.cps.DatabaseTestContainer; import org.onap.cps.spi.CpsAdminPersistenceService; import org.onap.cps.spi.entities.AnchorEntity; -import org.onap.cps.spi.entities.Dataspace; +import org.onap.cps.spi.entities.DataspaceEntity; import org.onap.cps.spi.exceptions.AnchorAlreadyDefinedException; import org.onap.cps.spi.exceptions.DataspaceAlreadyDefinedException; import org.onap.cps.spi.exceptions.DataspaceNotFoundException; @@ -83,10 +83,10 @@ public class CpsAdminPersistenceServiceTest { final String dataspaceName = "DATASPACE-NEW"; cpsAdminPersistenceService.createDataspace(dataspaceName); - final Dataspace dataspace = dataspaceRepository.findByName(dataspaceName).orElseThrow(); - assertNotNull(dataspace); - assertNotNull(dataspace.getId()); - assertEquals(dataspaceName, dataspace.getName()); + final DataspaceEntity dataspaceEntity = dataspaceRepository.findByName(dataspaceName).orElseThrow(); + assertNotNull(dataspaceEntity); + assertNotNull(dataspaceEntity.getId()); + assertEquals(dataspaceName, dataspaceEntity.getName()); } @Test(expected = DataspaceAlreadyDefinedException.class) @@ -101,9 +101,9 @@ public class CpsAdminPersistenceServiceTest { cpsAdminPersistenceService.createAnchor(DATASPACE_NAME, SCHEMA_SET_NAME2, ANCHOR_NAME_NEW); // validate anchor persisted - final Dataspace dataspace = dataspaceRepository.findByName(DATASPACE_NAME).orElseThrow(); + final DataspaceEntity dataspaceEntity = dataspaceRepository.findByName(DATASPACE_NAME).orElseThrow(); final AnchorEntity anchorEntity = - anchorRepository.findByDataspaceAndName(dataspace, ANCHOR_NAME_NEW).orElseThrow(); + anchorRepository.findByDataspaceAndName(dataspaceEntity, ANCHOR_NAME_NEW).orElseThrow(); assertNotNull(anchorEntity.getId()); assertEquals(ANCHOR_NAME_NEW, anchorEntity.getName()); diff --git a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java index 77c8003a1..e813d26bf 100644 --- a/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java +++ b/cps-ri/src/test/java/org/onap/cps/spi/impl/CpsModulePersistenceServiceTest.java @@ -30,9 +30,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.cps.DatabaseTestContainer; import org.onap.cps.spi.CpsModulePersistenceService; -import org.onap.cps.spi.entities.Dataspace; -import org.onap.cps.spi.entities.SchemaSet; -import org.onap.cps.spi.entities.YangResource; +import org.onap.cps.spi.entities.DataspaceEntity; +import org.onap.cps.spi.entities.SchemaSetEntity; +import org.onap.cps.spi.entities.YangResourceEntity; import org.onap.cps.spi.exceptions.DataspaceNotFoundException; import org.onap.cps.spi.exceptions.SchemaSetAlreadyDefinedException; import org.onap.cps.spi.repository.DataspaceRepository; @@ -124,33 +124,33 @@ public class CpsModulePersistenceServiceTest { final String expectedYangResourceChecksum) { // assert the schema set is persisted - final SchemaSet schemaSet = getSchemaSetFromDatabase(expectedDataspaceName, expectedSchemaSetName); - assertEquals(expectedDataspaceName, schemaSet.getDataspace().getName()); - assertEquals(expectedSchemaSetName, schemaSet.getName()); + final SchemaSetEntity schemaSetEntity = getSchemaSetFromDatabase(expectedDataspaceName, expectedSchemaSetName); + assertEquals(expectedDataspaceName, schemaSetEntity.getDataspace().getName()); + assertEquals(expectedSchemaSetName, schemaSetEntity.getName()); // assert the attached yang resource is persisted - final Set yangResources = schemaSet.getYangResources(); - assertNotNull(yangResources); - assertEquals(1, yangResources.size()); + final Set yangResourceEntities = schemaSetEntity.getYangResources(); + assertNotNull(yangResourceEntities); + assertEquals(1, yangResourceEntities.size()); // assert the attached yang resource content - final YangResource yangResource = yangResources.iterator().next(); - assertNotNull(yangResource.getId()); + final YangResourceEntity yangResourceEntity = yangResourceEntities.iterator().next(); + assertNotNull(yangResourceEntity.getId()); if (expectedYangResourceId != NEW_RESOURCE_ABSTRACT_ID) { // existing resource with known id - assertEquals(expectedYangResourceId, yangResource.getId()); + assertEquals(expectedYangResourceId, yangResourceEntity.getId()); } - assertEquals(expectedYangResourceName, yangResource.getName()); - assertEquals(expectedYangResourceContent, yangResource.getContent()); - assertEquals(expectedYangResourceChecksum, yangResource.getChecksum()); + assertEquals(expectedYangResourceName, yangResourceEntity.getName()); + assertEquals(expectedYangResourceContent, yangResourceEntity.getContent()); + assertEquals(expectedYangResourceChecksum, yangResourceEntity.getChecksum()); } private static Map toMap(final String key, final String value) { return ImmutableMap.builder().put(key, value).build(); } - private SchemaSet getSchemaSetFromDatabase(final String dataspaceName, final String schemaSetName) { - final Dataspace dataspace = dataspaceRepository.findByName(dataspaceName).orElseThrow(); - return schemaSetRepository.findByDataspaceAndName(dataspace, schemaSetName).orElseThrow(); + private SchemaSetEntity getSchemaSetFromDatabase(final String dataspaceName, final String schemaSetName) { + final DataspaceEntity dataspaceEntity = dataspaceRepository.findByName(dataspaceName).orElseThrow(); + return schemaSetRepository.findByDataspaceAndName(dataspaceEntity, schemaSetName).orElseThrow(); } } -- cgit 1.2.3-korg