| 1 | /* | |
| 2 |  * Copyright (c) 2013 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.domain; | |
| 17 | ||
| 18 | import java.io.Serializable; | |
| 19 | import java.util.Objects; | |
| 20 | import java.util.Optional; | |
| 21 | ||
| 22 | /** | |
| 23 |  * @author Maxim Yunusov | |
| 24 |  * @version 1.0 24.11.13 | |
| 25 |  */ | |
| 26 | public class Project implements Serializable { | |
| 27 | ||
| 28 |     private static final long serialVersionUID = -8859706675434765594L; | |
| 29 | ||
| 30 |     private String id; | |
| 31 | ||
| 32 |     private String name; | |
| 33 | ||
| 34 |     private int version; | |
| 35 | ||
| 36 |     private String description; | |
| 37 | ||
| 38 |     private String models; | |
| 39 | ||
| 40 |     private String view; | |
| 41 | ||
| 42 |     @SuppressWarnings("unused") | |
| 43 |     public Project() { | |
| 44 |     } | |
| 45 | ||
| 46 |     public Project(final String id, final String name, final int version, final String description) { | |
| 47 |         this.id = id; | |
| 48 |         this.name = name; | |
| 49 |         this.version = version; | |
| 50 |         this.description = description; | |
| 51 |     } | |
| 52 | /* | |
| 53 | ||
| 54 |     public Project cloneWith(final String rawData) { | |
| 55 |         final Project result = new Project(this.id, this.name, this.version); | |
| 56 |         result.raw = rawData; | |
| 57 |         return result; | |
| 58 |     }*/ | |
| 59 | ||
| 60 |     public Project brief() { | |
| 61 | 
1
1. brief : mutated return of Object value for org/maxur/perfmodel/backend/domain/Project::brief to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE | 
        return new Project(this.id, this.name, this.version, this.description); | 
| 62 |     } | |
| 63 | ||
| 64 |     public String getName() { | |
| 65 | 
1
1. getName : mutated return of Object value for org/maxur/perfmodel/backend/domain/Project::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE | 
        return name; | 
| 66 |     } | |
| 67 | ||
| 68 |     public String getId() { | |
| 69 | 
1
1. getId : mutated return of Object value for org/maxur/perfmodel/backend/domain/Project::getId to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE | 
        return id; | 
| 70 |     } | |
| 71 | ||
| 72 |     public int getVersion() { | |
| 73 | 
1
1. getVersion : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE | 
        return version; | 
| 74 |     } | |
| 75 | ||
| 76 |     public String getDescription() { | |
| 77 | 
1
1. getDescription : mutated return of Object value for org/maxur/perfmodel/backend/domain/Project::getDescription to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE | 
        return description; | 
| 78 |     } | |
| 79 | ||
| 80 |     public String getModels() { | |
| 81 | 
1
1. getModels : mutated return of Object value for org/maxur/perfmodel/backend/domain/Project::getModels to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE | 
        return models; | 
| 82 |     } | |
| 83 | ||
| 84 |     public String getView() { | |
| 85 | 
1
1. getView : mutated return of Object value for org/maxur/perfmodel/backend/domain/Project::getView to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE | 
        return view; | 
| 86 |     } | |
| 87 | ||
| 88 |     public void setModels(final String models) { | |
| 89 |         this.models = models; | |
| 90 |     } | |
| 91 | ||
| 92 |     public void setView(final String view) { | |
| 93 |         this.view = view; | |
| 94 |     } | |
| 95 | ||
| 96 |     public void incVersion() { | |
| 97 | 
1
1. incVersion : Replaced integer addition with subtraction → NO_COVERAGE | 
        this.version++; | 
| 98 |     } | |
| 99 | ||
| 100 |     public void makeVersion() { | |
| 101 |         this.version = 1; | |
| 102 |     } | |
| 103 | ||
| 104 |     public void checkUniqueId(Optional<Project> otherWithSameId) throws ConflictException { | |
| 105 | 
1
1. checkUniqueId : negated conditional → NO_COVERAGE | 
        if (otherWithSameId.isPresent()) { | 
| 106 |             throw new ConflictException("Another project with same id '%s' already exists.", id); | |
| 107 |         } | |
| 108 |     } | |
| 109 | ||
| 110 |     public boolean isSame(final Optional<Project> other) { | |
| 111 | 
1
1. isSame : negated conditional → NO_COVERAGE | 
        if (!other.isPresent()) { | 
| 112 | 
1
1. isSame : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE | 
            return false; | 
| 113 |         } | |
| 114 |         Project project = other.get(); | |
| 115 | 
1
1. isSame : negated conditional → NO_COVERAGE | 
        return Objects.equals(id, project.id) | 
| 116 | 
2
1. isSame : negated conditional → NO_COVERAGE 2. isSame : negated conditional → NO_COVERAGE  | 
                && Objects.equals(this.name, project.name) | 
| 117 |                 && this.version == project.version | |
| 118 | 
1
1. isSame : negated conditional → NO_COVERAGE | 
                && Objects.equals(this.description, project.description) | 
| 119 | 
1
1. isSame : negated conditional → NO_COVERAGE | 
                && Objects.equals(this.models, project.models) | 
| 120 | 
2
1. isSame : negated conditional → NO_COVERAGE 2. isSame : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE  | 
                && Objects.equals(this.view, project.view); | 
| 121 |     } | |
| 122 | ||
| 123 |     public void checkNamesakes(final Optional<Project> namesake) throws ConflictException { | |
| 124 | 
1
1. checkNamesakes : negated conditional → NO_COVERAGE | 
        if (namesake.isPresent()) { | 
| 125 | 
1
1. checkNamesakes : negated conditional → NO_COVERAGE | 
            if (!namesake.get().getId().equals(id)) { | 
| 126 |                 throw new ConflictException("Another project with same '%s' already exists.", name); | |
| 127 |             } | |
| 128 |         } | |
| 129 |     } | |
| 130 | ||
| 131 |     public void checkConflictWith(final Optional<Project> prevVersionOfThisProject) throws ConflictException { | |
| 132 | 
1
1. checkConflictWith : negated conditional → NO_COVERAGE | 
        if (prevVersionOfThisProject.isPresent()) { | 
| 133 | 
2
1. checkConflictWith : Replaced integer subtraction with addition → NO_COVERAGE 2. checkConflictWith : negated conditional → NO_COVERAGE  | 
            if (version - 1 != prevVersionOfThisProject.get().version) { | 
| 134 |                 throw new ConflictException("Project '%s' has been changed by another user.", name); | |
| 135 |             } | |
| 136 |         } | |
| 137 |     } | |
| 138 | ||
| 139 |     @Override | |
| 140 |     public boolean equals(Object o) { | |
| 141 | 
1
1. equals : negated conditional → NO_COVERAGE | 
        if (this == o) { | 
| 142 | 
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE | 
            return true; | 
| 143 |         } | |
| 144 | 
2
1. equals : negated conditional → NO_COVERAGE 2. equals : negated conditional → NO_COVERAGE  | 
        if (o == null || getClass() != o.getClass()) { | 
| 145 | 
1
1. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE | 
            return false; | 
| 146 |         } | |
| 147 |         final Project project = (Project) o; | |
| 148 | 
3
1. equals : negated conditional → NO_COVERAGE 2. equals : negated conditional → NO_COVERAGE 3. equals : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE  | 
        return Objects.equals(version, project.version) && Objects.equals(id, project.id); | 
| 149 |     } | |
| 150 | ||
| 151 |     @Override | |
| 152 |     public int hashCode() { | |
| 153 | 
1
1. hashCode : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE | 
        return Objects.hash(id, version); | 
| 154 |     } | |
| 155 | ||
| 156 |     @Override | |
| 157 |     public String toString() { | |
| 158 | 
1
1. toString : mutated return of Object value for org/maxur/perfmodel/backend/domain/Project::toString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE | 
        return "Project{" + | 
| 159 |                 "id='" + id + '\'' + | |
| 160 |                 ", name='" + name + '\'' + | |
| 161 |                 ", version=" + version + | |
| 162 |                 '}'; | |
| 163 |     } | |
| 164 | ||
| 165 | } | |
Mutations | ||
| 61 | 
 
 1.1  | 
|
| 65 | 
 
 1.1  | 
|
| 69 | 
 
 1.1  | 
|
| 73 | 
 
 1.1  | 
|
| 77 | 
 
 1.1  | 
|
| 81 | 
 
 1.1  | 
|
| 85 | 
 
 1.1  | 
|
| 97 | 
 
 1.1  | 
|
| 105 | 
 
 1.1  | 
|
| 111 | 
 
 1.1  | 
|
| 112 | 
 
 1.1  | 
|
| 115 | 
 
 1.1  | 
|
| 116 | 
 
 1.1 2.2  | 
|
| 118 | 
 
 1.1  | 
|
| 119 | 
 
 1.1  | 
|
| 120 | 
 
 1.1 2.2  | 
|
| 124 | 
 
 1.1  | 
|
| 125 | 
 
 1.1  | 
|
| 132 | 
 
 1.1  | 
|
| 133 | 
 
 1.1 2.2  | 
|
| 141 | 
 
 1.1  | 
|
| 142 | 
 
 1.1  | 
|
| 144 | 
 
 1.1 2.2  | 
|
| 145 | 
 
 1.1  | 
|
| 148 | 
 
 1.1 2.2 3.3  | 
|
| 153 | 
 
 1.1  | 
|
| 158 | 
 
 1.1  |