From b65f161be0539fb80a91dea2f8250885656358f4 Mon Sep 17 00:00:00 2001 From: Nima Eskandary Date: Tue, 14 May 2019 16:43:39 -0400 Subject: [PATCH 1/3] add change type to delete batch input --- .../java/model/batch/AddChangeInput.java | 49 ++++--------------- .../java/model/batch/ChangeInput.java | 41 ++++++++++++++-- .../batch/DeleteRecordSetChangeInput.java | 38 +++----------- .../java/responses/VinylDNSResponse.java | 2 +- .../io/vinyldns/java/VinylDNSClientTest.java | 49 +++++++++++++------ 5 files changed, 88 insertions(+), 91 deletions(-) diff --git a/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java index b9a1f30..46fc555 100644 --- a/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java @@ -17,38 +17,16 @@ import io.vinyldns.java.model.record.data.RecordData; import java.util.Objects; -public class AddChangeInput implements ChangeInput { - private String inputName; - - private RecordType type; - +public class AddChangeInput extends ChangeInput { private Long ttl; - private RecordData record; - private ChangeInputType changeType = ChangeInputType.Add; - public AddChangeInput(String inputName, RecordType type, Long ttl, RecordData record) { - this.inputName = inputName; - this.type = type; + super(ChangeInputType.Add, inputName, type); this.ttl = ttl; this.record = record; } - @Override - public ChangeInputType getChangeType() { - return changeType; - } - - @Override - public String getInputName() { - return inputName; - } - - public RecordType getType() { - return type; - } - public Long getTtl() { return ttl; } @@ -59,17 +37,9 @@ public RecordData getRecord() { @Override public String toString() { - return "AddChangeInput{" - + "inputName='" - + inputName - + '\'' - + ", type=" - + type - + ", ttl=" - + ttl - + ", record=" - + record - + '}'; + return String.format( + "AddChangeInput{changeType='%s', inputName='%s', recordType='%s', ttl='%s', record='%s'}", + this.getChangeType(), this.getInputName(), this.getRecordType(), this.ttl, this.record); } @Override @@ -77,14 +47,13 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AddChangeInput that = (AddChangeInput) o; - return Objects.equals(inputName, that.inputName) - && type == that.type - && Objects.equals(ttl, that.ttl) - && Objects.equals(record, that.record); + return super.equals(o) + && Objects.equals(this.ttl, that.ttl) + && Objects.equals(this.record, that.record); } @Override public int hashCode() { - return Objects.hash(inputName, type, ttl, record); + return super.hashCode() + Objects.hash(ttl, record); } } diff --git a/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java index 380093e..8b201a5 100644 --- a/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java @@ -13,9 +13,44 @@ */ package io.vinyldns.java.model.batch; -public interface ChangeInput { +import io.vinyldns.java.model.record.RecordType; +import java.util.Objects; - ChangeInputType getChangeType(); +public class ChangeInput { + private ChangeInputType changeType; + private String inputName; + private RecordType recordType; - String getInputName(); + public ChangeInput(ChangeInputType changeType, String inputName, RecordType recordType) { + this.changeType = changeType; + this.inputName = inputName; + this.recordType = recordType; + } + + public ChangeInputType getChangeType() { + return changeType; + } + + public String getInputName() { + return inputName; + } + + public RecordType getRecordType() { + return recordType; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ChangeInput that = (ChangeInput) o; + return this.inputName.equals(that.inputName) + && this.changeType == that.changeType + && this.recordType == that.recordType; + } + + @Override + public int hashCode() { + return Objects.hash(inputName, changeType, recordType); + } } diff --git a/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java index 45ce7f7..2d68479 100644 --- a/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java @@ -13,41 +13,17 @@ */ package io.vinyldns.java.model.batch; -import java.util.Objects; +import io.vinyldns.java.model.record.RecordType; -public class DeleteRecordSetChangeInput implements ChangeInput { - private String inputName; - - public DeleteRecordSetChangeInput(String inputName) { - this.inputName = inputName; - } - - @Override - public ChangeInputType getChangeType() { - return ChangeInputType.DeleteRecordSet; - } - - @Override - public String getInputName() { - return inputName; +public class DeleteRecordSetChangeInput extends ChangeInput { + public DeleteRecordSetChangeInput(String inputName, RecordType recordType) { + super(ChangeInputType.DeleteRecordSet, inputName, recordType); } @Override public String toString() { - return "DeleteRecordSetChangeInput{" + "inputName='" + inputName + '\'' + '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DeleteRecordSetChangeInput that = (DeleteRecordSetChangeInput) o; - return Objects.equals(inputName, that.inputName); - } - - @Override - public int hashCode() { - - return Objects.hash(inputName); + return String.format( + "DeleteRecordSetChangeInput{changeType='%s', inputName='%s', recordType='%s'}", + this.getChangeType().name(), this.getInputName(), this.getRecordType().name()); } } diff --git a/src/main/java/io/vinyldns/java/responses/VinylDNSResponse.java b/src/main/java/io/vinyldns/java/responses/VinylDNSResponse.java index b82a718..244aa19 100644 --- a/src/main/java/io/vinyldns/java/responses/VinylDNSResponse.java +++ b/src/main/java/io/vinyldns/java/responses/VinylDNSResponse.java @@ -40,7 +40,7 @@ public int getStatusCode() { @Override public String toString() { - return "value=" + value + ", statusCode=" + statusCode; + return "value=" + value + ", messageBody=" + messageBody + ", statusCode=" + statusCode; } @Override diff --git a/src/test/java/io/vinyldns/java/VinylDNSClientTest.java b/src/test/java/io/vinyldns/java/VinylDNSClientTest.java index b6a8187..521b35b 100644 --- a/src/test/java/io/vinyldns/java/VinylDNSClientTest.java +++ b/src/test/java/io/vinyldns/java/VinylDNSClientTest.java @@ -1066,27 +1066,44 @@ public void createBatchChangeSuccess() { List changes = new ArrayList<>(); AData adata = new AData("1.2.3.4"); - AddChangeInput input = new AddChangeInput("www.example.com", RecordType.A, 300L, adata); - changes.add(input); + AddChangeInput addInput = new AddChangeInput("www.example.com", RecordType.A, 300L, adata); + DeleteRecordSetChangeInput deleteInput = + new DeleteRecordSetChangeInput("www.example.com", RecordType.A); + changes.add(addInput); + changes.add(deleteInput); CreateBatchRequest batchRequest = new CreateBatchRequest(changes); - AddSingleChange singleChange = new AddSingleChange(); - singleChange.setChangeType(ChangeInputType.Add); - singleChange.setId("1234"); - singleChange.setInputName("testString"); - singleChange.setRecord(adata); - singleChange.setRecordChangeId("1111"); - singleChange.setRecordName("testName"); - singleChange.setRecordSetId("testId"); - singleChange.setZoneId("testZone"); - singleChange.setZoneName("testZoneName"); - singleChange.setType(RecordType.A); - singleChange.setSystemMessage("testMessage"); - singleChange.setStatus(SingleChangeStatus.Complete); + AddSingleChange addSingleChange = new AddSingleChange(); + addSingleChange.setChangeType(ChangeInputType.Add); + addSingleChange.setId("1234"); + addSingleChange.setInputName("testString"); + addSingleChange.setRecord(adata); + addSingleChange.setRecordChangeId("1111"); + addSingleChange.setRecordName("testName"); + addSingleChange.setRecordSetId("testId"); + addSingleChange.setZoneId("testZone"); + addSingleChange.setZoneName("testZoneName"); + addSingleChange.setType(RecordType.A); + addSingleChange.setSystemMessage("testMessage"); + addSingleChange.setStatus(SingleChangeStatus.Complete); + + DeleteRecordSetSingleChange deleteSingleChange = new DeleteRecordSetSingleChange(); + deleteSingleChange.setChangeType(ChangeInputType.DeleteRecordSet); + deleteSingleChange.setId("1234"); + deleteSingleChange.setInputName("testString"); + deleteSingleChange.setRecordChangeId("1111"); + deleteSingleChange.setRecordName("testName"); + deleteSingleChange.setRecordSetId("testId"); + deleteSingleChange.setZoneId("testZone"); + deleteSingleChange.setZoneName("testZoneName"); + deleteSingleChange.setTyp(RecordType.A); + deleteSingleChange.setSystemMessage("testMessage"); + deleteSingleChange.setStatus(SingleChangeStatus.Complete); List singleChangeList = new ArrayList<>(); - singleChangeList.add(singleChange); + singleChangeList.add(addSingleChange); + singleChangeList.add(deleteSingleChange); BatchResponse batchResponse = new BatchResponse(); batchResponse.setId("1234"); From 8fadba15131cc006c72abe327186cd515505b27d Mon Sep 17 00:00:00 2001 From: Nima Eskandary Date: Thu, 16 May 2019 12:50:41 -0400 Subject: [PATCH 2/3] review --- .../java/model/batch/AddChangeInput.java | 6 +++--- .../vinyldns/java/model/batch/ChangeInput.java | 18 +++++++++--------- .../batch/DeleteRecordSetChangeInput.java | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java index 46fc555..70c12c6 100644 --- a/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java @@ -18,8 +18,8 @@ import java.util.Objects; public class AddChangeInput extends ChangeInput { - private Long ttl; - private RecordData record; + private final Long ttl; + private final RecordData record; public AddChangeInput(String inputName, RecordType type, Long ttl, RecordData record) { super(ChangeInputType.Add, inputName, type); @@ -39,7 +39,7 @@ public RecordData getRecord() { public String toString() { return String.format( "AddChangeInput{changeType='%s', inputName='%s', recordType='%s', ttl='%s', record='%s'}", - this.getChangeType(), this.getInputName(), this.getRecordType(), this.ttl, this.record); + this.getChangeType(), this.getInputName(), this.getType(), this.ttl, this.record); } @Override diff --git a/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java index 8b201a5..8f37047 100644 --- a/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/ChangeInput.java @@ -17,14 +17,14 @@ import java.util.Objects; public class ChangeInput { - private ChangeInputType changeType; - private String inputName; - private RecordType recordType; + private final ChangeInputType changeType; + private final String inputName; + private final RecordType type; - public ChangeInput(ChangeInputType changeType, String inputName, RecordType recordType) { + public ChangeInput(ChangeInputType changeType, String inputName, RecordType type) { this.changeType = changeType; this.inputName = inputName; - this.recordType = recordType; + this.type = type; } public ChangeInputType getChangeType() { @@ -35,8 +35,8 @@ public String getInputName() { return inputName; } - public RecordType getRecordType() { - return recordType; + public RecordType getType() { + return type; } @Override @@ -46,11 +46,11 @@ public boolean equals(Object o) { ChangeInput that = (ChangeInput) o; return this.inputName.equals(that.inputName) && this.changeType == that.changeType - && this.recordType == that.recordType; + && this.type == that.type; } @Override public int hashCode() { - return Objects.hash(inputName, changeType, recordType); + return Objects.hash(inputName, changeType, type); } } diff --git a/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java index 2d68479..3f1b0bd 100644 --- a/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java @@ -16,14 +16,14 @@ import io.vinyldns.java.model.record.RecordType; public class DeleteRecordSetChangeInput extends ChangeInput { - public DeleteRecordSetChangeInput(String inputName, RecordType recordType) { - super(ChangeInputType.DeleteRecordSet, inputName, recordType); + public DeleteRecordSetChangeInput(String inputName, RecordType type) { + super(ChangeInputType.DeleteRecordSet, inputName, type); } @Override public String toString() { return String.format( "DeleteRecordSetChangeInput{changeType='%s', inputName='%s', recordType='%s'}", - this.getChangeType().name(), this.getInputName(), this.getRecordType().name()); + this.getChangeType().name(), this.getInputName(), this.getType().name()); } } From e6caac63827bd6d644d1898ef582a9ec4e52833e Mon Sep 17 00:00:00 2001 From: Nima Eskandary Date: Thu, 16 May 2019 13:04:56 -0400 Subject: [PATCH 3/3] type --- src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java | 2 +- .../vinyldns/java/model/batch/DeleteRecordSetChangeInput.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java index 70c12c6..82f294b 100644 --- a/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/AddChangeInput.java @@ -38,7 +38,7 @@ public RecordData getRecord() { @Override public String toString() { return String.format( - "AddChangeInput{changeType='%s', inputName='%s', recordType='%s', ttl='%s', record='%s'}", + "AddChangeInput{changeType='%s', inputName='%s', type='%s', ttl='%s', record='%s'}", this.getChangeType(), this.getInputName(), this.getType(), this.ttl, this.record); } diff --git a/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java b/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java index 3f1b0bd..b65ae88 100644 --- a/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java +++ b/src/main/java/io/vinyldns/java/model/batch/DeleteRecordSetChangeInput.java @@ -23,7 +23,7 @@ public DeleteRecordSetChangeInput(String inputName, RecordType type) { @Override public String toString() { return String.format( - "DeleteRecordSetChangeInput{changeType='%s', inputName='%s', recordType='%s'}", + "DeleteRecordSetChangeInput{changeType='%s', inputName='%s', type='%s'}", this.getChangeType().name(), this.getInputName(), this.getType().name()); } }