Skip to content

Commit 92c0b90

Browse files
committed
fixing code format and some of the tests
1 parent 9c6c297 commit 92c0b90

File tree

13 files changed

+70
-1698
lines changed

13 files changed

+70
-1698
lines changed

language/automl/entity-extraction/java/src/main/java/com/google/cloud/language/automl/entity/extraction/samples/DeleteModel.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.google.cloud.language.automl.entity.extraction.samples;
22

33
// [START automl_natural_language_entity_delete_model]
4+
import com.google.api.gax.longrunning.OperationFuture;
45
import com.google.cloud.automl.v1beta1.AutoMlClient;
56
import com.google.cloud.automl.v1beta1.ModelName;
7+
import com.google.cloud.automl.v1beta1.OperationMetadata;
68
import com.google.protobuf.Empty;
79
import java.io.IOException;
810
import java.util.concurrent.ExecutionException;
@@ -22,10 +24,10 @@ public static void deleteModel(String projectId, String computeRegion, String mo
2224
ModelName modelFullId = ModelName.of(projectId, computeRegion, modelId);
2325

2426
// Delete a model.
25-
Empty response = client.deleteModelAsync(modelFullId).get();
27+
OperationFuture<Empty, OperationMetadata> response = client.deleteModelAsync(modelFullId);
2628

2729
System.out.println("Model deletion started...");
28-
System.out.println(String.format("Model deleted. %s", response));
30+
System.out.println(String.format("Model deleted. %s", response.getName()));
2931
}
3032
}
3133
// [END automl_natural_language_entity_delete_model]

language/automl/entity-extraction/java/src/main/java/com/google/cloud/language/automl/entity/extraction/samples/ModelApi.java

Lines changed: 0 additions & 675 deletions
This file was deleted.

language/automl/entity-extraction/java/src/main/java/com/google/cloud/language/automl/entity/extraction/samples/PredictionApi.java

Lines changed: 0 additions & 131 deletions
This file was deleted.

language/automl/entity-extraction/java/src/test/java/com/google/cloud/language/automl/entity/extraction/samples/DatasetIT.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@
3535
import org.junit.runner.RunWith;
3636
import org.junit.runners.JUnit4;
3737

38-
/** Tests for AutoML Natural Language Entity Extraction "Dataset API" sample. */
38+
/** Tests for AutoML Natural Language Entity Extraction Dataset operations */
3939
@RunWith(JUnit4.class)
4040
public class DatasetIT {
41-
// TODO(developer): Change PROJECT_ID, COMPUTE_REGION, DATASET_ID and IMPORT_DATA_CSV before
42-
// running the test cases.
43-
private static final String PROJECT_ID = "java-docs-samples-testing";
41+
42+
private static final String PROJECT_ID = System.getenv("PROJECT_ID");
4443
private static final String OUTPUT_PREFIX = "AUTOML_LANGUAGE_ENTITY_TEST_OUTPUT";
4544
private static final String COMPUTE_REGION = "us-central1";
4645
private static final String DATASET_NAME = "test_language_dataset";

language/automl/entity-extraction/java/src/test/java/com/google/cloud/language/automl/entity/extraction/samples/ModelIT.java

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,21 @@
2121
import java.io.ByteArrayOutputStream;
2222
import java.io.IOException;
2323
import java.io.PrintStream;
24-
import java.util.concurrent.ExecutionException;
2524

2625
import org.junit.After;
2726
import org.junit.Before;
2827
import org.junit.Test;
2928
import org.junit.runner.RunWith;
3029
import org.junit.runners.JUnit4;
3130

32-
/** Tests for AutoML Natural Language Entity Extraction "Model API" sample. */
31+
/** Tests for AutoML Natural Language Entity Extraction Model operations. */
3332
@RunWith(JUnit4.class)
3433
public class ModelIT {
35-
// TODO(developer): Change PROJECT_ID, COMPUTE_REGION, DATASET_ID, DEPLOY_MODEL_ID
36-
// and UNDEPLOY_MODEL_ID before running the test cases.
37-
private static final String PROJECT_ID = "java-docs-samples-testing";
34+
35+
private static final String PROJECT_ID = System.getenv("PROJECT_ID");
3836
private static final String COMPUTE_REGION = "us-central1";
3937
private static final String FILTER = "textExtractionModelMetadata:*";
40-
private static final String DATASET_ID = "TEN3391966983409893376";
41-
private static final String MODEL_NAME = "test_entity_model";
42-
private static final String DEPLOY_MODEL_ID = "TEN7560470651006353408";
43-
private static final String UNDEPLOY_MODEL_ID = "TEN6287640806320766976";
38+
private static final String MODEL_ID = "TEN1974951581904273408";
4439

4540
private ByteArrayOutputStream bout;
4641
private PrintStream out;
@@ -58,34 +53,26 @@ public void tearDown() {
5853
}
5954

6055
@Test
61-
public void testModelOperations() throws IOException, InterruptedException, ExecutionException {
62-
// Act
63-
CreateModel.createModel(PROJECT_ID, COMPUTE_REGION, DATASET_ID, MODEL_NAME);
64-
65-
// Assert
66-
String got = bout.toString();
67-
assertThat(got).contains("Training started...");
56+
public void testModelOperations() throws Exception {
6857

6958
// Act
70-
bout.reset();
7159
ListModels.listModels(PROJECT_ID, COMPUTE_REGION, FILTER);
7260

7361
// Assert
74-
got = bout.toString();
75-
String modelId = got.split("\n")[2].split("/")[got.split("\n")[2].split("/").length - 1];
76-
assertThat(got).contains("Model Id:");
62+
String got = bout.toString();
63+
assertThat(got).contains(MODEL_ID);
7764

7865
// Act
7966
bout.reset();
80-
GetModel.getModel(PROJECT_ID, COMPUTE_REGION, modelId);
67+
GetModel.getModel(PROJECT_ID, COMPUTE_REGION, MODEL_ID);
8168

8269
// Assert
8370
got = bout.toString();
84-
assertThat(got).contains("Model name:");
71+
assertThat(got).contains(MODEL_ID);
8572

8673
// Act
8774
bout.reset();
88-
ListModelEvaluations.listModelEvaluations(PROJECT_ID, COMPUTE_REGION, modelId, "");
75+
ListModelEvaluations.listModelEvaluations(PROJECT_ID, COMPUTE_REGION, MODEL_ID, "");
8976

9077
// Assert
9178
got = bout.toString();
@@ -94,53 +81,26 @@ public void testModelOperations() throws IOException, InterruptedException, Exec
9481

9582
// Act
9683
bout.reset();
97-
GetModelEvaluation.getModelEvaluation(PROJECT_ID, COMPUTE_REGION, modelId, modelEvaluationId);
84+
GetModelEvaluation.getModelEvaluation(PROJECT_ID, COMPUTE_REGION, MODEL_ID, modelEvaluationId);
9885

9986
// Assert
10087
got = bout.toString();
10188
assertThat(got).contains("Model evaluation name:");
10289

10390
// Act
10491
bout.reset();
105-
DisplayEvaluation.displayEvaluation(PROJECT_ID, COMPUTE_REGION, modelId, "");
92+
DisplayEvaluation.displayEvaluation(PROJECT_ID, COMPUTE_REGION, MODEL_ID, "");
10693

10794
// Assert
10895
got = bout.toString();
10996
assertThat(got).contains("Model Evaluation ID:");
11097

111-
// Act
112-
bout.reset();
113-
DeleteModel.deleteModel(PROJECT_ID, COMPUTE_REGION, modelId);
114-
115-
// Assert
116-
got = bout.toString();
117-
assertThat(got).contains("Model deletion started...");
118-
}
119-
120-
@Test
121-
public void testDeployModel() throws Exception {
122-
// Act
123-
DeployModel.deployModel(PROJECT_ID, COMPUTE_REGION, DEPLOY_MODEL_ID);
124-
125-
// Assert
126-
String got = bout.toString();
127-
assertThat(got).contains("Name:");
128-
}
129-
130-
@Test
131-
public void testUndeployModel() throws Exception {
132-
// Act
133-
UndeployModel.undeployModel(PROJECT_ID, COMPUTE_REGION, UNDEPLOY_MODEL_ID);
134-
135-
// Assert
136-
String got = bout.toString();
137-
assertThat(got).contains("Name:");
13898
}
13999

140100
@Test
141101
public void testOperationStatus() throws IOException {
142102
// Act
143-
ModelApi.listOperationsStatus(PROJECT_ID, COMPUTE_REGION, "");
103+
ListOperationsStatus.listOperationsStatus(PROJECT_ID, COMPUTE_REGION, "");
144104

145105
// Assert
146106
String got = bout.toString();

language/automl/entity-extraction/java/src/test/java/com/google/cloud/language/automl/entity/extraction/samples/PredictIT.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
import org.junit.runner.RunWith;
2929
import org.junit.runners.JUnit4;
3030

31+
/** Tests for AutoML Natural Language Sentiment Analysis Prediction. */
3132
@RunWith(JUnit4.class)
3233
public class PredictIT {
33-
// TODO(developer): Change PROJECT_ID, COMPUTE_REGION and MODEL_ID before running the
34-
// test cases.
35-
private static final String PROJECT_ID = "java-docs-samples-testing";
34+
35+
private static final String PROJECT_ID = System.getenv("PROJECT_ID");
3636
private static final String COMPUTE_REGION = "us-central1";
37-
private static final String MODEL_ID = "TEN368697035118870528";
38-
private static final String FILE_PATH = "./resource/entityInput.txt";
37+
private static final String MODEL_ID = "TEN1974951581904273408";
38+
private static final String FILE_PATH = "./resources/entityInput.txt";
3939
private ByteArrayOutputStream bout;
4040
private PrintStream out;
4141

@@ -59,5 +59,6 @@ public void testPredict() throws IOException {
5959
// Assert
6060
String got = bout.toString();
6161
assertThat(got).contains("Prediction results:");
62+
assertThat(got).contains("2");
6263
}
6364
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deliberative thinker who employs a thorough and conscientious approach to research
1+
VLCAD deficiency . These results suggested the heterogenous nature of the mutations causing the deficiency in the seven patients . Clinically , all patients with VLCAD deficiency exhibited cardiac disease . At least four of them presented with hypertrophic cardiomyopathy . This frequency ( > 57 % ) was much higher than that observed in patients with other disorders of mitochondrial long-chain fatty acid oxidation that may be accompanied by cardiac disease in infants
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
In the third quarter of 2010 , net sales increased by 5.2 % to EUR 205.5 mn , and operating profit by 34.9 % to EUR 23.5 mn .
1+
the pharmacy had me sign something when I bought the Claritin-D saying I wouldn't use it to make drugs lol

language/automl/sentiment-analysis/java/src/main/java/com/google/cloud/language/automl/sentiment/analysis/samples/DatasetApi.java

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)