@Test public void transform() { Item item = createItem(1); replayAll(); CassandraInstance instance = SdbCassandraInstanceDao.transform(item); assertEquals(1, instance.getId()); assertEquals("dc1", instance.getDataCenter()); assertEquals("rack1", instance.getRack()); assertEquals("host1", instance.getHostName()); assertEquals("publicIpAddress1", instance.getPublicIpAddress()); }
@VisibleForTesting static CassandraInstance transform(Item item) { CassandraInstance.Builder instanceBuilder = new CassandraInstance.Builder(); for (Attribute attr : item.getAttributes()) { if (attr.getName().equals(ID_KEY)) { instanceBuilder.id(Integer.parseInt(attr.getValue())); } else if (attr.getName().equals(DATACENTER_KEY)) { instanceBuilder.dataCenter(attr.getValue()); } else if (attr.getName().equals(RACK_KEY)) { instanceBuilder.rack(attr.getValue()); } else if (attr.getName().equals(HOSTNAME_KEY)) { instanceBuilder.hostName(attr.getValue()); } else if (attr.getName().equals(PUBLIC_IP_ADDRESS_KEY)) { instanceBuilder.publicIpAddress(attr.getValue()); } else if (attr.getName().equals(FULLY_QUALIFIED_DOMAIN_NAME_KEY)) { instanceBuilder.fullyQualifiedDomainName(attr.getValue()); } } return instanceBuilder.build(); }
SdbCassandraInstanceDao implements CassandraInstanceDao { @VisibleForTesting static CassandraInstance transform(Item item) { CassandraInstance.Builder instanceBuilder = new CassandraInstance.Builder(); for (Attribute attr : item.getAttributes()) { if (attr.getName().equals(ID_KEY)) { instanceBuilder.id(Integer.parseInt(attr.getValue())); } else if (attr.getName().equals(DATACENTER_KEY)) { instanceBuilder.dataCenter(attr.getValue()); } else if (attr.getName().equals(RACK_KEY)) { instanceBuilder.rack(attr.getValue()); } else if (attr.getName().equals(HOSTNAME_KEY)) { instanceBuilder.hostName(attr.getValue()); } else if (attr.getName().equals(PUBLIC_IP_ADDRESS_KEY)) { instanceBuilder.publicIpAddress(attr.getValue()); } else if (attr.getName().equals(FULLY_QUALIFIED_DOMAIN_NAME_KEY)) { instanceBuilder.fullyQualifiedDomainName(attr.getValue()); } } return instanceBuilder.build(); } }
SdbCassandraInstanceDao implements CassandraInstanceDao { @VisibleForTesting static CassandraInstance transform(Item item) { CassandraInstance.Builder instanceBuilder = new CassandraInstance.Builder(); for (Attribute attr : item.getAttributes()) { if (attr.getName().equals(ID_KEY)) { instanceBuilder.id(Integer.parseInt(attr.getValue())); } else if (attr.getName().equals(DATACENTER_KEY)) { instanceBuilder.dataCenter(attr.getValue()); } else if (attr.getName().equals(RACK_KEY)) { instanceBuilder.rack(attr.getValue()); } else if (attr.getName().equals(HOSTNAME_KEY)) { instanceBuilder.hostName(attr.getValue()); } else if (attr.getName().equals(PUBLIC_IP_ADDRESS_KEY)) { instanceBuilder.publicIpAddress(attr.getValue()); } else if (attr.getName().equals(FULLY_QUALIFIED_DOMAIN_NAME_KEY)) { instanceBuilder.fullyQualifiedDomainName(attr.getValue()); } } return instanceBuilder.build(); } @Inject  SdbCassandraInstanceDao(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory); }
SdbCassandraInstanceDao implements CassandraInstanceDao { @VisibleForTesting static CassandraInstance transform(Item item) { CassandraInstance.Builder instanceBuilder = new CassandraInstance.Builder(); for (Attribute attr : item.getAttributes()) { if (attr.getName().equals(ID_KEY)) { instanceBuilder.id(Integer.parseInt(attr.getValue())); } else if (attr.getName().equals(DATACENTER_KEY)) { instanceBuilder.dataCenter(attr.getValue()); } else if (attr.getName().equals(RACK_KEY)) { instanceBuilder.rack(attr.getValue()); } else if (attr.getName().equals(HOSTNAME_KEY)) { instanceBuilder.hostName(attr.getValue()); } else if (attr.getName().equals(PUBLIC_IP_ADDRESS_KEY)) { instanceBuilder.publicIpAddress(attr.getValue()); } else if (attr.getName().equals(FULLY_QUALIFIED_DOMAIN_NAME_KEY)) { instanceBuilder.fullyQualifiedDomainName(attr.getValue()); } } return instanceBuilder.build(); } @Inject  SdbCassandraInstanceDao(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory); @Override ImmutableSet<CassandraInstance> findAll(String ring); @Override @Nullable CassandraInstance findById(String ring, int id); @Override void save(String ring, CassandraInstance instance); @Override void delete(String ring, CassandraInstance instance); }
SdbCassandraInstanceDao implements CassandraInstanceDao { @VisibleForTesting static CassandraInstance transform(Item item) { CassandraInstance.Builder instanceBuilder = new CassandraInstance.Builder(); for (Attribute attr : item.getAttributes()) { if (attr.getName().equals(ID_KEY)) { instanceBuilder.id(Integer.parseInt(attr.getValue())); } else if (attr.getName().equals(DATACENTER_KEY)) { instanceBuilder.dataCenter(attr.getValue()); } else if (attr.getName().equals(RACK_KEY)) { instanceBuilder.rack(attr.getValue()); } else if (attr.getName().equals(HOSTNAME_KEY)) { instanceBuilder.hostName(attr.getValue()); } else if (attr.getName().equals(PUBLIC_IP_ADDRESS_KEY)) { instanceBuilder.publicIpAddress(attr.getValue()); } else if (attr.getName().equals(FULLY_QUALIFIED_DOMAIN_NAME_KEY)) { instanceBuilder.fullyQualifiedDomainName(attr.getValue()); } } return instanceBuilder.build(); } @Inject  SdbCassandraInstanceDao(AmazonSimpleDBClient client, CassandraDomainFactory domainFactory); @Override ImmutableSet<CassandraInstance> findAll(String ring); @Override @Nullable CassandraInstance findById(String ring, int id); @Override void save(String ring, CassandraInstance instance); @Override void delete(String ring, CassandraInstance instance);  }