package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
import java.io.Serializable;
-import java.util.Date;
+import java.time.Instant;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
private ToscaConceptIdentifier controlLoopElementId;
@NonNull
- private Date timeStamp;
+ private Instant timeStamp;
@NonNull
private ControlLoopState controlLoopState;
package org.onap.policy.clamp.controlloop.models.controlloop.concepts;
import java.io.Serializable;
-import java.util.Date;
+import java.time.Instant;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
private ToscaConceptIdentifier participantId;
@NonNull
- private Date timeStamp;
+ private Instant timeStamp;
private ParticipantState state;
private ParticipantHealthStatus healthStatus;
package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
import java.io.Serializable;
-import java.util.Date;
import java.util.List;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@VerifyKey
@NotNull
// @formatter:off
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "cl_element_name")),
- @AttributeOverride(name = "version", column = @Column(name = "cl_element_version"))
- })
+ @AttributeOverride(name = "name", column = @Column(name = "cl_element_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "cl_element_version"))
private PfConceptKey clElementId;
// @formatter: on
this.fromAuthorative(authorativeConcept);
}
-
-
@Override
public ClElementStatistics toAuthorative() {
ClElementStatistics clElementStatistics = new ClElementStatistics();
- clElementStatistics.setTimeStamp(new Date(key.getTimeStamp().getTime()));
+ clElementStatistics.setTimeStamp(key.getTimeStamp().toInstant());
clElementStatistics.setControlLoopElementId(new ToscaConceptIdentifier(clElementId));
clElementStatistics.setControlLoopState(state);
clElementStatistics.setClElementUptime(clElementUptime);
package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts;
import java.io.Serializable;
-import java.util.Date;
import java.util.List;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
-public class JpaParticipantStatistics extends PfConcept
- implements PfAuthorative<ParticipantStatistics>, Serializable {
+public class JpaParticipantStatistics extends PfConcept implements PfAuthorative<ParticipantStatistics>, Serializable {
private static final long serialVersionUID = -5992214428190133190L;
@VerifyKey
@NotNull
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "participant_name")),
- @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
- }
- )
+ @AttributeOverride(name = "name", column = @Column(name = "participant_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "participant_version"))
private PfConceptKey participantId;
@Column
* @param key the key
*/
public JpaParticipantStatistics(@NonNull final PfTimestampKey key) {
- this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L,
- 0.0d, 0L, 0L, 0L);
+ this(key, new PfConceptKey(), ParticipantState.PASSIVE, ParticipantHealthStatus.HEALTHY, 0L, 0L, 0.0d, 0L, 0L,
+ 0L);
}
@Override
public ParticipantStatistics toAuthorative() {
ParticipantStatistics participantStatistics = new ParticipantStatistics();
- participantStatistics.setTimeStamp(new Date(key.getTimeStamp().getTime()));
+ participantStatistics.setTimeStamp(key.getTimeStamp().toInstant());
participantStatistics.setParticipantId(new ToscaConceptIdentifier(participantId));
participantStatistics.setState(state);
participantStatistics.setHealthStatus(healthStatus);
public void fromAuthorative(@NonNull final ParticipantStatistics participantStatistics) {
if (this.key == null || this.getKey().isNullKey()) {
this.setKey(new PfTimestampKey(participantStatistics.getParticipantId().getName(),
- participantStatistics.getParticipantId().getVersion(),
- participantStatistics.getTimeStamp()));
+ participantStatistics.getParticipantId().getVersion(), participantStatistics.getTimeStamp()));
}
this.setParticipantId(participantStatistics.getParticipantId().asConceptKey());
this.setState(participantStatistics.getState());
key.clean();
participantId.clean();
}
-}
\ No newline at end of file
+}
package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
* @throws PfModelException on errors getting clElement statistics
*/
public List<ClElementStatistics> getClElementStatistics(final String name, final String version,
- final Date timestamp) throws PfModelException {
+ final Instant timestamp) throws PfModelException {
if (name != null && version != null && timestamp != null) {
List<ClElementStatistics> clElementStatistics = new ArrayList<>(1);
* @throws PfModelException on errors getting policies
*/
public List<ClElementStatistics> getFilteredClElementStatistics(final String name, final String version,
- final Date startTimeStamp, final Date endTimeStamp, Map<String, Object> filterMap, final String sortOrder,
- final int getRecordNum) {
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap,
+ final String sortOrder, final int getRecordNum) {
return asClElementStatisticsList(getPfDao().getFiltered(JpaClElementStatistics.class, name, version,
startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
}
package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider;
+import java.time.Instant;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
* @throws PfModelException on errors getting participant statistics
*/
public List<ParticipantStatistics> getParticipantStatistics(final String name, final String version,
- final Date timestamp) throws PfModelException {
+ final Instant timestamp) throws PfModelException {
if (name != null && version != null && timestamp != null) {
List<ParticipantStatistics> participantStatistics = new ArrayList<>(1);
* @throws PfModelException on errors getting policies
*/
public List<ParticipantStatistics> getFilteredParticipantStatistics(final String name, final String version,
- final Date startTimeStamp, final Date endTimeStamp, Map<String, Object> filterMap, final String sortOrder,
- final int getRecordNum) {
+ final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap,
+ final String sortOrder, final int getRecordNum) {
return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, name, version,
startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum));
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import java.util.Date;
+import java.time.Instant;
import org.junit.Test;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
ClElementStatistics cles1 = new ClElementStatistics();
cles1.setControlLoopElementId(new ToscaConceptIdentifier("defName", "0.0.1"));
- cles1.setTimeStamp(new Date(System.currentTimeMillis()));
+ cles1.setTimeStamp(Instant.now());
assertThat(cles1.toString()).contains("ClElementStatistics(");
assertEquals(false, cles1.hashCode() == 0);
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
-import java.util.Date;
+import java.time.Instant;
import org.junit.Test;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
ParticipantStatistics ps1 = new ParticipantStatistics();
ps1.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
- ps1.setTimeStamp(new Date(System.currentTimeMillis()));
+ ps1.setTimeStamp(Instant.now());
assertThat(ps1.toString()).contains("ParticipantStatistics(");
assertEquals(false, ps1.hashCode() == 0);
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.util.Date;
+import java.time.Instant;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
testJpaClElementStatisticsFa.setKey(PfTimestampKey.getNullKey());
testJpaClElementStatisticsFa.fromAuthorative(cles);
assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
- testJpaClElementStatisticsFa.setKey(new PfTimestampKey("elementName", "0.0.1", new Date(123456L)));
+ testJpaClElementStatisticsFa.setKey(new PfTimestampKey("elementName", "0.0.1", Instant.ofEpochMilli(123456L)));
testJpaClElementStatisticsFa.fromAuthorative(cles);
assertEquals(testJpaClElementStatistics, testJpaClElementStatisticsFa);
private ClElementStatistics createClElementStatisticsInstance() {
ClElementStatistics clElementStatistics = new ClElementStatistics();
clElementStatistics.setControlLoopElementId(new ToscaConceptIdentifier("elementName", "0.0.1"));
- clElementStatistics.setTimeStamp(new Date(123456L));
+ clElementStatistics.setTimeStamp(Instant.ofEpochMilli(123456L));
clElementStatistics.setControlLoopState(ControlLoopState.UNINITIALISED);
return clElementStatistics;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.util.Date;
+import java.time.Instant;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantHealthStatus;
testJpaParticipantStatisticsFa.setKey(PfTimestampKey.getNullKey());
testJpaParticipantStatisticsFa.fromAuthorative(cles);
assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
- testJpaParticipantStatisticsFa.setKey(new PfTimestampKey("participantName", "0.0.1", new Date(123456L)));
+ testJpaParticipantStatisticsFa
+ .setKey(new PfTimestampKey("participantName", "0.0.1", Instant.ofEpochMilli(123456L)));
testJpaParticipantStatisticsFa.fromAuthorative(cles);
assertEquals(testJpaParticipantStatistics, testJpaParticipantStatisticsFa);
private ParticipantStatistics createParticipantStatisticsInstance() {
ParticipantStatistics participantStatistics = new ParticipantStatistics();
participantStatistics.setParticipantId(new ToscaConceptIdentifier("participantName", "0.0.1"));
- participantStatistics.setTimeStamp(new Date(123456L));
+ participantStatistics.setTimeStamp(Instant.ofEpochMilli(123456L));
participantStatistics.setState(ParticipantState.PASSIVE);
participantStatistics.setHealthStatus(ParticipantHealthStatus.HEALTHY);
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
.getClElementStatistics());
ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0)
.getControlLoopElementId();
- Date date = inputClElementStats.getClElementStatistics().get(0).getTimeStamp();
+ Instant instant = inputClElementStats.getClElementStatistics().get(0).getTimeStamp();
assertEquals(1, clElementStatisticsProvider.getClElementStatistics(identifier.getName(),
- identifier.getVersion(), date).size());
+ identifier.getVersion(), instant).size());
assertEquals(1, clElementStatisticsProvider.getFilteredClElementStatistics("name2",
"1.0.1", null, null, null,
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
-import java.util.Date;
+import java.time.Instant;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
participantStatisticsProvider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
ToscaConceptIdentifier identifier = inputParticipantStatistics.getStatisticsList().get(0).getParticipantId();
- Date date = inputParticipantStatistics.getStatisticsList().get(0).getTimeStamp();
+ Instant instant = inputParticipantStatistics.getStatisticsList().get(0).getTimeStamp();
assertEquals(1, participantStatisticsProvider
- .getParticipantStatistics(identifier.getName(), identifier.getVersion(), date).size());
+ .getParticipantStatistics(identifier.getName(), identifier.getVersion(), instant).size());
assertEquals(1, participantStatisticsProvider
.getFilteredParticipantStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());