use of com.globo.globodns.cloudstack.commands.RemoveDomainCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testRemoveDomainWithSuccessWhenDomainExistsAndThereAreOnlyNSRecordsAndOverrideIsFalse.
@Test
public void testRemoveDomainWithSuccessWhenDomainExistsAndThereAreOnlyNSRecordsAndOverrideIsFalse() throws Exception {
String domainName = "domain.name.com";
Domain domain = generateFakeDomain(domainName, false);
List<Record> recordList = new ArrayList<Record>();
for (int i = 0; i < 10; i++) {
Record record = new Record();
record.getTypeNSRecordAttributes().setDomainId(domain.getId());
record.getTypeNSRecordAttributes().setId(sequenceId++);
record.getTypeNSRecordAttributes().setType("NS");
recordList.add(record);
}
when(_recordApi.listAll(domain.getId())).thenReturn(recordList);
Answer answer = _globoDnsResource.execute(new RemoveDomainCommand(domainName, false));
assertEquals(true, answer.getResult());
verify(_domainApi, times(1)).removeDomain(eq(domain.getId()));
verify(_exportApi, times(1)).scheduleExport();
}
use of com.globo.globodns.cloudstack.commands.RemoveDomainCommand in project cloudstack by apache.
the class GloboDnsElement method destroy.
@Override
@DB
public boolean destroy(final Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
Long zoneId = network.getDataCenterId();
final DataCenter zone = _dcDao.findById(zoneId);
if (zone == null) {
throw new CloudRuntimeException("Could not find zone associated to this network");
}
RemoveDomainCommand cmd = new RemoveDomainCommand(network.getNetworkDomain(), GloboDNSOverride.value());
callCommand(cmd, zoneId);
return true;
}
use of com.globo.globodns.cloudstack.commands.RemoveDomainCommand in project cloudstack by apache.
the class GloboDnsResourceTest method testRemoveDomainWithSuccessWhenDomainExistsAndThereAreRecordsAndOverrideIsTrue.
@Test
public void testRemoveDomainWithSuccessWhenDomainExistsAndThereAreRecordsAndOverrideIsTrue() throws Exception {
String domainName = "domain.name.com";
Domain domain = generateFakeDomain(domainName, false);
List<Record> recordList = new ArrayList<Record>();
for (int i = 0; i < 10; i++) {
Record record = new Record();
record.getTypeNSRecordAttributes().setDomainId(domain.getId());
record.getTypeNSRecordAttributes().setId(sequenceId++);
record.getTypeNSRecordAttributes().setType(new String[] { "A", "NS", "PTR" }[i % 3]);
recordList.add(record);
}
when(_recordApi.listAll(domain.getId())).thenReturn(recordList);
Answer answer = _globoDnsResource.execute(new RemoveDomainCommand(domainName, true));
assertEquals(true, answer.getResult());
verify(_domainApi, times(1)).removeDomain(eq(domain.getId()));
verify(_exportApi, times(1)).scheduleExport();
}
Aggregations