</parent>
<dependencies>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-extras</artifactId>
package org.openecomp.sdc.versioning.dao.types;
+import lombok.Getter;
+import lombok.Setter;
import java.util.Date;
+@Getter
+@Setter
public class Revision {
private String id;
private String message;
private Date time;
private String user;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public void setTime(Date time) {
- this.time = time;
- }
-
- public String getMessage() {
- return message;
- }
-
- public Date getTime() {
- return time;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
}
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.UDT;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
@UDT(name = "user_candidate_version", keyspace = "dox")
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
public class UserCandidateVersion {
-
+ private String user;
@Frozen
private Version version;
- private String user;
-
- public UserCandidateVersion() {
- }
-
- public UserCandidateVersion(String user, Version candidateVersion) {
- this.user = user;
- this.version = candidateVersion;
- }
-
- public Version getVersion() {
- return version;
- }
-
- public void setVersion(Version version) {
- this.version = version;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
}
+
import com.datastax.driver.mapping.annotations.Transient;
import com.datastax.driver.mapping.annotations.UDT;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import java.util.Date;
import java.util.Map;
@UDT(name = "version", keyspace = "dox")
+@Getter
+@Setter
+@NoArgsConstructor
public class Version {
public static final String VERSION_STRING_VIOLATION_MSG =
"Version string must be in the format of: {integer}.{integer}";
@Transient
private Map<String, Object> additionalInfo;
- public Version() {
- }
-
public Version(String id) {
this.id = id;
}
return version;
}
-
- public int getMajor() {
- return major;
- }
-
- public void setMajor(int major) {
- this.major = major;
- }
-
- public int getMinor() {
- return minor;
- }
-
- public void setMinor(int minor) {
- this.minor = minor;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getBaseId() {
- return baseId;
- }
-
- public void setBaseId(String baseId) {
- this.baseId = baseId;
- }
-
- public Date getCreationTime() {
- return creationTime;
- }
-
- public void setCreationTime(Date creationTime) {
- this.creationTime = creationTime;
- }
-
- public Date getModificationTime() {
- return modificationTime;
- }
-
- public void setModificationTime(Date modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- public VersionStatus getStatus() {
- return status;
- }
-
- public void setStatus(VersionStatus status) {
- this.status = status;
- }
-
- public VersionState getState() {
- return state;
- }
-
- public void setState(VersionState state) {
- this.state = state;
- }
-
public Version calculateNextCandidate() {
return new Version(major, minor + 1);
}
return major != 0 && minor == 0;
}
- public Map<String, Object> getAdditionalInfo() {
- return additionalInfo;
- }
-
- public void setAdditionalInfo(Map<String, Object> additionalInfo) {
- this.additionalInfo = additionalInfo;
- }
-
@Override
public int hashCode() {
int result = major;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
@Table(keyspace = "dox", name = "version_history")
+@Getter
+@Setter
+@NoArgsConstructor
public class VersionHistoryEntity {
@PartitionKey
private String description;
private VersionType type;
- /**
- * Every entity class must have a default constructor according to
- * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
- * Definition of mapped classes</a>.
- */
- public VersionHistoryEntity() {
- // Don't delete! Default constructor is required by DataStax driver
- }
-
public VersionHistoryEntity(VersionableEntityId entityId) {
this.entityId = entityId;
}
-
- public VersionableEntityId getEntityId() {
- return entityId;
- }
-
- public void setEntityId(VersionableEntityId entityId) {
- this.entityId = entityId;
- }
-
- public Version getVersion() {
- return version;
- }
-
- public void setVersion(Version version) {
- this.version = version;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public VersionType getType() {
- return type;
- }
-
- public void setType(VersionType type) {
- this.type = type;
- }
}
import com.datastax.driver.mapping.annotations.FrozenValue;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import java.util.HashSet;
import java.util.Set;
@Table(keyspace = "dox", name = "version_info_deleted")
+@Getter
+@Setter
+@NoArgsConstructor
public class VersionInfoDeletedEntity {
@PartitionKey
@Frozen
private Version latestFinalVersion;
- /**
- * Every entity class must have a default constructor according to
- * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
- * Definition of mapped classes</a>.
- */
- public VersionInfoDeletedEntity() {
- // Don't delete! Default constructor is required by DataStax driver
- }
-
public VersionInfoDeletedEntity(String entityType, String entityId) {
this.entityType = entityType;
this.entityId = entityId;
}
- public String getEntityType() {
- return entityType;
- }
-
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- public String getEntityId() {
- return entityId;
- }
-
- public void setEntityId(String entityId) {
- this.entityId = entityId;
- }
-
- public Version getActiveVersion() {
- return activeVersion;
- }
-
- public void setActiveVersion(Version activeVersion) {
- this.activeVersion = activeVersion;
- }
-
- public VersionStatus getStatus() {
- return status;
- }
-
- public void setStatus(VersionStatus status) {
- this.status = status;
- }
-
- public UserCandidateVersion getCandidate() {
- return candidate;
- }
-
- public void setCandidate(UserCandidateVersion candidate) {
- this.candidate = candidate;
- }
-
- public Set<Version> getViewableVersions() {
- return viewableVersions;
- }
-
- public void setViewableVersions(Set<Version> viewableVersions) {
- this.viewableVersions = viewableVersions;
- }
-
- public Version getLatestFinalVersion() {
- return latestFinalVersion;
- }
-
- public void setLatestFinalVersion(Version latestFinalVersion) {
- this.latestFinalVersion = latestFinalVersion;
- }
}
import com.datastax.driver.mapping.annotations.FrozenValue;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import java.util.HashSet;
import java.util.Set;
@Table(keyspace = "dox", name = "version_info")
+@Getter
+@Setter
+@NoArgsConstructor
public class VersionInfoEntity {
@PartitionKey
@Frozen
private Version latestFinalVersion;
- /**
- * Every entity class must have a default constructor according to
- * <a href="http://docs.datastax.com/en/developer/java-driver/2.1/manual/object_mapper/creating/">
- * Definition of mapped classes</a>.
- */
- public VersionInfoEntity() {
- // Don't delete! Default constructor is required by DataStax driver
- }
-
public VersionInfoEntity(String entityType, String entityId) {
this.entityType = entityType;
this.entityId = entityId;
}
-
- public String getEntityType() {
- return entityType;
- }
-
- public void setEntityType(String entityType) {
- this.entityType = entityType;
- }
-
- public String getEntityId() {
- return entityId;
- }
-
- public void setEntityId(String entityId) {
- this.entityId = entityId;
- }
-
- public Version getActiveVersion() {
- return activeVersion;
- }
-
- public void setActiveVersion(Version activeVersion) {
- this.activeVersion = activeVersion;
- }
-
- public VersionStatus getStatus() {
- return status;
- }
-
- public void setStatus(VersionStatus status) {
- this.status = status;
- }
-
- public UserCandidateVersion getCandidate() {
- return candidate;
- }
-
- public void setCandidate(UserCandidateVersion candidate) {
- this.candidate = candidate;
- }
-
- public Set<Version> getViewableVersions() {
- return viewableVersions;
- }
-
- public void setViewableVersions(Set<Version> viewableVersions) {
- this.viewableVersions = viewableVersions;
- }
-
- public Version getLatestFinalVersion() {
- return latestFinalVersion;
- }
-
- public void setLatestFinalVersion(Version latestFinalVersion) {
- this.latestFinalVersion = latestFinalVersion;
- }
}
package org.openecomp.sdc.versioning.dao.types;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
public class VersionState {
private SynchronizationState synchronizationState;
private boolean dirty;
-
- public SynchronizationState getSynchronizationState() {
- return synchronizationState;
- }
-
- public void setSynchronizationState(
- SynchronizationState synchronizationState) {
- this.synchronizationState = synchronizationState;
- }
-
- public boolean isDirty() {
- return dirty;
- }
-
- public void setDirty(boolean dirty) {
- this.dirty = dirty;
- }
}
package org.openecomp.sdc.versioning.dao.types;
import com.datastax.driver.mapping.annotations.UDT;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
@UDT(name = "versionable_entity_id", keyspace = "dox")
+@Getter
+@Setter
+@NoArgsConstructor
+@AllArgsConstructor
public class VersionableEntityId {
private String type;
private String id;
-
- public VersionableEntityId() {
- }
-
- public VersionableEntityId(String type, String id) {
- this.type = type;
- this.id = id;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
}
--- /dev/null
+/*
+ *
+ * Copyright © 2017-2018 European Support Limited
+ *
+ * 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.
+ *
+ */
+package org.openecomp.sdc.versioning.dao.types;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class VersionTest {
+ @Test
+ public void testValueOfPositive() {
+ Version version = Version.valueOf("1.1");
+ Assert.assertEquals(1, version.getMajor());
+ Assert.assertEquals(1, version.getMinor());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testValueOfWihLengthOne() {
+ Version version = Version.valueOf("1");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testValueOfNegative() {
+ Version version = Version.valueOf("1a.1");
+ }
+ @Test
+ public void testValueOfNullVersion() {
+ Version version = Version.valueOf(null);
+ Assert.assertNull(version);
+ }
+
+ @Test
+ public void testCalculateNextCandidate() {
+ Version version = new Version();
+ version.setMinor(1);
+ Assert.assertEquals(2, version.calculateNextCandidate().getMinor());
+ }
+
+ @Test
+ public void testCalculateNextCandidateFinal() {
+ Version version = new Version();
+ version.setMajor(0);
+ Assert.assertEquals(1, version.calculateNextFinal().getMajor());
+ }
+
+ @Test
+ public void testCompareTo() {
+ Version version = new Version();
+ version.setMajor(1);
+
+ Version versionToCompare = new Version();
+ versionToCompare.setMajor(1);
+ Assert.assertEquals(0, version.compareTo(versionToCompare));
+ }
+
+ @Test
+ public void testVersionEquals() {
+ Version version = new Version();
+ version.setMajor(0);
+ version.setMinor(2);
+ Version versionToCompare = new Version();
+ versionToCompare.setMajor(0);
+ versionToCompare.setMinor(2);
+
+ Assert.assertTrue(version.equals(versionToCompare));
+ }
+
+ @Test
+ public void testVersionClone() {
+ Version version = new Version("1.0");
+ Assert.assertEquals(version, version.clone());
+ }
+
+ @Test
+ public void testVersionHashcode() {
+ Version version = new Version("1.0");
+ Assert.assertEquals((31 * (version.getMajor())+ version.getMinor()), version.hashCode());
+ }
+}
\ No newline at end of file