| 1 | /* | |
| 2 | * Copyright (c) 2015 Maxim Yunusov | |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | * you may not use this file except in compliance with the License. | |
| 5 | * You may obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, software | |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 | * See the License for the specific language governing permissions and | |
| 13 | * limitations under the License. | |
| 14 | */ | |
| 15 | ||
| 16 | package org.maxur.perfmodel.backend.rest.dto; | |
| 17 | ||
| 18 | import com.fasterxml.jackson.annotation.JsonRawValue; | |
| 19 | import com.fasterxml.jackson.databind.JsonNode; | |
| 20 | import org.jsondoc.core.annotation.ApiObject; | |
| 21 | import org.jsondoc.core.annotation.ApiObjectField; | |
| 22 | import org.maxur.perfmodel.backend.domain.Project; | |
| 23 | ||
| 24 | import javax.xml.bind.annotation.XmlRootElement; | |
| 25 | import java.io.Serializable; | |
| 26 | import java.util.Collection; | |
| 27 | import java.util.List; | |
| 28 | ||
| 29 | import static java.util.stream.Collectors.toList; | |
| 30 | ||
| 31 | /** | |
| 32 | * @author Maxim Yunusov | |
| 33 | * @version 1.0 24.11.13 | |
| 34 | */ | |
| 35 | @SuppressWarnings("unused") | |
| 36 | @XmlRootElement | |
| 37 | @ApiObject(name = "Project") | |
| 38 | public class ProjectDto implements Serializable { | |
| 39 | ||
| 40 | private static final long serialVersionUID = -5236202133124299315L; | |
| 41 | ||
| 42 | @ApiObjectField(required = true, description = "The project identifier") | |
| 43 | private String id; | |
| 44 | ||
| 45 | @ApiObjectField(required = true, description = "The project name") | |
| 46 | private String name; | |
| 47 | ||
| 48 | @ApiObjectField(required = true, description = "The project version") | |
| 49 | private int version; | |
| 50 | ||
| 51 | @ApiObjectField(required = false, description = "The project description") | |
| 52 | private String description; | |
| 53 | ||
| 54 | @ApiObjectField(required = false, description = "The Serialized presentation of the object's models", format="[]") | |
| 55 | @JsonRawValue | |
| 56 | private String models; | |
| 57 | ||
| 58 | @ApiObjectField(required = false, description = "The Serialized presentation of the object's view", format="{}") | |
| 59 | @JsonRawValue | |
| 60 | private String view; | |
| 61 | ||
| 62 | @SuppressWarnings("UnusedDeclaration") | |
| 63 | public ProjectDto() { | |
| 64 | } | |
| 65 | ||
| 66 | public ProjectDto(final String id, final String name, final int version, final String description) { | |
| 67 | this.id = id; | |
| 68 | this.name = name; | |
| 69 | this.version = version; | |
| 70 | this.description = description; | |
| 71 | } | |
| 72 | ||
| 73 | public String getId() { | |
| 74 |
1
1. getId : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::getId to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return id; |
| 75 | } | |
| 76 | ||
| 77 | ||
| 78 | public String getName() { | |
| 79 |
1
1. getName : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return name; |
| 80 | } | |
| 81 | ||
| 82 | public int getVersion() { | |
| 83 |
1
1. getVersion : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return version; |
| 84 | } | |
| 85 | ||
| 86 | public String getDescription() { | |
| 87 |
1
1. getDescription : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::getDescription to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return description; |
| 88 | } | |
| 89 | ||
| 90 | public String getModels() { | |
| 91 |
1
1. getModels : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::getModels to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return models; |
| 92 | } | |
| 93 | ||
| 94 | public String getView() { | |
| 95 |
1
1. getView : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::getView to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return view; |
| 96 | } | |
| 97 | ||
| 98 | public void setModels(final JsonNode models) { | |
| 99 |
1
1. setModels : negated conditional → NO_COVERAGE |
this.models = models == null ? null : models.toString(); |
| 100 | } | |
| 101 | ||
| 102 | public void setView(final JsonNode view) { | |
| 103 |
1
1. setView : negated conditional → NO_COVERAGE |
this.view = view == null ? null : view.toString(); |
| 104 | } | |
| 105 | ||
| 106 | /** | |
| 107 | * Creation method. Create DTO List by Project List. | |
| 108 | * <p> | |
| 109 | * @param all list of Projects. | |
| 110 | * @return project's dto List. | |
| 111 | */ | |
| 112 | public static List<ProjectDto> dtoList(final Collection<Project> all) { | |
| 113 |
1
1. dtoList : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::dtoList to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return all.stream().map(ProjectDto::dto).collect(toList()); |
| 114 | } | |
| 115 | ||
| 116 | /** | |
| 117 | * Creation method. Create Full DTO by Project. | |
| 118 | * <p> | |
| 119 | * @param project domain object 'Project'. | |
| 120 | * @return project's dto. | |
| 121 | */ | |
| 122 | public static ProjectDto dto(final Project project) { | |
| 123 | final ProjectDto dto = | |
| 124 | new ProjectDto(project.getId(), project.getName(), project.getVersion(), project.getDescription()); | |
| 125 | dto.models = project.getModels(); | |
| 126 | dto.view = project.getView(); | |
| 127 |
1
1. dto : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::dto to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return dto; |
| 128 | } | |
| 129 | ||
| 130 | /** | |
| 131 | * Create entity object 'Project' from this dto. | |
| 132 | * | |
| 133 | * @return The Project. | |
| 134 | */ | |
| 135 | public Project assemble() { | |
| 136 | final Project result = new Project(id, name, version, description); | |
| 137 |
1
1. assemble : removed call to org/maxur/perfmodel/backend/domain/Project::setModels → NO_COVERAGE |
result.setModels(models); |
| 138 |
1
1. assemble : removed call to org/maxur/perfmodel/backend/domain/Project::setView → NO_COVERAGE |
result.setView(view); |
| 139 |
1
1. assemble : mutated return of Object value for org/maxur/perfmodel/backend/rest/dto/ProjectDto::assemble to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result; |
| 140 | } | |
| 141 | } | |
Mutations | ||
| 74 |
1.1 |
|
| 79 |
1.1 |
|
| 83 |
1.1 |
|
| 87 |
1.1 |
|
| 91 |
1.1 |
|
| 95 |
1.1 |
|
| 99 |
1.1 |
|
| 103 |
1.1 |
|
| 113 |
1.1 |
|
| 127 |
1.1 |
|
| 137 |
1.1 |
|
| 138 |
1.1 |
|
| 139 |
1.1 |