@Test public void testGetAttributeNames() throws TranslatorException { String domainName = "abc"; DomainMetadataResult domainMetadataResult = Mockito.mock(DomainMetadataResult.class); when(domainMetadataResult.getAttributeNameCount()).thenReturn(0); when(simpleDBClient.domainMetadata(any(DomainMetadataRequest.class))).thenReturn(domainMetadataResult); SelectResult selectResult = Mockito.mock(SelectResult.class); when(simpleDBClient.select(new SelectRequest("SELECT * FROM " + SimpleDBUtils.quoteName(domainName)))) .thenReturn(selectResult); simpleDBConnection.getAttributeNames(domainName); }
@Override public Set<SimpleDBAttribute> getAttributeNames(String domainName) throws TranslatorException { DomainMetadataRequest domainMetadataRequest = new DomainMetadataRequest(domainName); DomainMetadataResult metadataResult = amazonSimpleDBClient.domainMetadata(domainMetadataRequest); int attributesCount = metadataResult.getAttributeNameCount(); SelectResult selectResult = amazonSimpleDBClient.select(new SelectRequest("SELECT * FROM " + SimpleDBUtils.quoteName(domainName))); return getAttributeNamesFromSelectResult(selectResult, attributesCount); }
SimpleDBConnectionImpl implements SimpleDBConnection { @Override public Set<SimpleDBAttribute> getAttributeNames(String domainName) throws TranslatorException { DomainMetadataRequest domainMetadataRequest = new DomainMetadataRequest(domainName); DomainMetadataResult metadataResult = amazonSimpleDBClient.domainMetadata(domainMetadataRequest); int attributesCount = metadataResult.getAttributeNameCount(); SelectResult selectResult = amazonSimpleDBClient.select(new SelectRequest("SELECT * FROM " + SimpleDBUtils.quoteName(domainName))); return getAttributeNamesFromSelectResult(selectResult, attributesCount); } }
SimpleDBConnectionImpl implements SimpleDBConnection { @Override public Set<SimpleDBAttribute> getAttributeNames(String domainName) throws TranslatorException { DomainMetadataRequest domainMetadataRequest = new DomainMetadataRequest(domainName); DomainMetadataResult metadataResult = amazonSimpleDBClient.domainMetadata(domainMetadataRequest); int attributesCount = metadataResult.getAttributeNameCount(); SelectResult selectResult = amazonSimpleDBClient.select(new SelectRequest("SELECT * FROM " + SimpleDBUtils.quoteName(domainName))); return getAttributeNamesFromSelectResult(selectResult, attributesCount); } SimpleDBConnectionImpl(AmazonSimpleDB amazonSimpleDBClient); }
SimpleDBConnectionImpl implements SimpleDBConnection { @Override public Set<SimpleDBAttribute> getAttributeNames(String domainName) throws TranslatorException { DomainMetadataRequest domainMetadataRequest = new DomainMetadataRequest(domainName); DomainMetadataResult metadataResult = amazonSimpleDBClient.domainMetadata(domainMetadataRequest); int attributesCount = metadataResult.getAttributeNameCount(); SelectResult selectResult = amazonSimpleDBClient.select(new SelectRequest("SELECT * FROM " + SimpleDBUtils.quoteName(domainName))); return getAttributeNamesFromSelectResult(selectResult, attributesCount); } SimpleDBConnectionImpl(AmazonSimpleDB amazonSimpleDBClient); @Override void createDomain(String domainName); @Override void deleteDomain(String domainName); @Override List<String> getDomains(); @Override Set<SimpleDBAttribute> getAttributeNames(String domainName); @Override int performInsert(String domainName, List<Column> columns, Iterator<? extends List<?>> valueList); @Override SelectResult performSelect(String selectExpression, String nextToken); @Override int performUpdate(String domainName, Map<String, Object> updateAttributes, String selectExpression); @Override int performDelete(String domainName, String selectExpression); @Override void close(); }
SimpleDBConnectionImpl implements SimpleDBConnection { @Override public Set<SimpleDBAttribute> getAttributeNames(String domainName) throws TranslatorException { DomainMetadataRequest domainMetadataRequest = new DomainMetadataRequest(domainName); DomainMetadataResult metadataResult = amazonSimpleDBClient.domainMetadata(domainMetadataRequest); int attributesCount = metadataResult.getAttributeNameCount(); SelectResult selectResult = amazonSimpleDBClient.select(new SelectRequest("SELECT * FROM " + SimpleDBUtils.quoteName(domainName))); return getAttributeNamesFromSelectResult(selectResult, attributesCount); } SimpleDBConnectionImpl(AmazonSimpleDB amazonSimpleDBClient); @Override void createDomain(String domainName); @Override void deleteDomain(String domainName); @Override List<String> getDomains(); @Override Set<SimpleDBAttribute> getAttributeNames(String domainName); @Override int performInsert(String domainName, List<Column> columns, Iterator<? extends List<?>> valueList); @Override SelectResult performSelect(String selectExpression, String nextToken); @Override int performUpdate(String domainName, Map<String, Object> updateAttributes, String selectExpression); @Override int performDelete(String domainName, String selectExpression); @Override void close();  }