use of li.naska.bgg.resource.v3.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method deleteDocumentIsSuccessful.
@Test
public void deleteDocumentIsSuccessful() {
Collection collection = createTestCollection();
String collectionId = collection.getCollectionId();
DocumentAccepted documentAccepted = createTestDocument("test_document", collectionId);
DeleteDocumentOptions deleteOptions = new DeleteDocumentOptions.Builder(environmentId, collectionId, documentAccepted.getDocumentId()).build();
discovery.deleteDocument(deleteOptions).execute();
}
use of li.naska.bgg.resource.v3.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method createCollectionIsSuccessful.
// Collection tests
@Test
public void createCollectionIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(createCollResp));
CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).configurationId(configurationId);
Collection response = discoveryService.createCollection(createCollectionBuilder.build()).execute();
RecordedRequest request = server.takeRequest();
assertEquals(COLL1_PATH, request.getPath());
assertEquals(POST, request.getMethod());
assertEquals(createCollResp, response);
}
use of li.naska.bgg.resource.v3.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceTest method getCollectionIsSuccessful.
@Test
public void getCollectionIsSuccessful() throws InterruptedException {
server.enqueue(jsonResponse(getCollResp));
GetCollectionOptions getRequest = new GetCollectionOptions.Builder(environmentId, collectionId).build();
Collection response = discoveryService.getCollection(getRequest).execute();
RecordedRequest request = server.takeRequest();
assertEquals(COLL2_PATH, request.getPath());
assertEquals(GET, request.getMethod());
assertEquals(getCollResp, response);
}
use of li.naska.bgg.resource.v3.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method queryWithNestedAggregationTermIsSuccessful.
@Test
public void queryWithNestedAggregationTermIsSuccessful() {
Collection collection = createTestCollection();
String collectionId = collection.getCollectionId();
createTestDocument("test_document_1", collectionId);
createTestDocument("test_document_2", collectionId);
QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId);
StringBuilder sb = new StringBuilder();
sb.append(AggregationType.TERM);
sb.append(Operator.OPENING_GROUPING);
sb.append("field");
sb.append(Operator.CLOSING_GROUPING);
sb.append(Operator.NEST_AGGREGATION);
sb.append(AggregationType.TERM);
sb.append(Operator.OPENING_GROUPING);
sb.append("field");
sb.append(Operator.CLOSING_GROUPING);
String aggregation = sb.toString();
queryBuilder.aggregation(aggregation);
QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute();
Term term = (Term) queryResponse.getAggregations().get(0);
AggregationResult agResults = term.getResults().get(0);
List<QueryAggregation> aggregations = agResults.getAggregations();
assertFalse(aggregations.isEmpty());
}
use of li.naska.bgg.resource.v3.model.Collection in project java-sdk by watson-developer-cloud.
the class DiscoveryServiceIT method updateCollectionIsSuccessful.
@Test
public void updateCollectionIsSuccessful() {
String uniqueCollectionName = uniqueName + "-collection";
CreateCollectionOptions createOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName).build();
Collection collection = createCollection(createOptions);
assertNotNull(collection.getCollectionId());
Configuration testConfig = createTestConfig();
String updatedCollectionName = UUID.randomUUID().toString() + "-collection";
String updatedCollectionDescription = "Description for " + updatedCollectionName;
UpdateCollectionOptions.Builder updateBuilder = new UpdateCollectionOptions.Builder(environmentId, collection.getCollectionId());
updateBuilder.name(updatedCollectionName);
updateBuilder.description(updatedCollectionDescription);
updateBuilder.configurationId(testConfig.getConfigurationId());
Collection updatedCollection = discovery.updateCollection(updateBuilder.build()).execute();
assertEquals(updatedCollectionName, updatedCollection.getName());
assertEquals(updatedCollectionDescription, updatedCollection.getDescription());
assertEquals(testConfig.getConfigurationId(), updatedCollection.getConfigurationId());
}
Aggregations