Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand JSON test coverage; add datastore and cloud storage #443

Merged
merged 22 commits into from
Sep 8, 2017
Merged

Conversation

elharo
Copy link
Contributor

@elharo elharo commented Aug 25, 2017


@Override
public int hashCode() {
return (groupId + ":" + artifactId + ":" + version).hashCode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Objects.hash()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to avoid dependencies is possible. This seems simple enough and I like the connection with the Gradle dependency ID format.

if (o == null || !(o instanceof MavenCoordinates)) {
return false;
}
MavenCoordinates other = (MavenCoordinates) o;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equals() needs to check repository, classifier, and type. Use Object.equals()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did wonder about that. For this use case, I'm not sure I want those included. If we're pulling the same dependency from two repos, I want to flag that. Is it reasonable for us to have two different dependencies for the same artifact with different classifiers or types?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The classifier and type are pretty key coordinates. I think you should have a different method for identifying equivalence that ignores repository. Or perhaps the repository should not be a coordinate at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you mention it, what I really need to verify here is that the groupId:artifactId is unique, not even including version.

Assert.assertTrue(status,
"beta".equals(status) || "alpha".equals(status) || "GA".equals(status));
new URI(client.getString("apireference"));
Assert.assertTrue("1.7.0".equals(client.getString("languageLevel")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The precision seems odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. ATM, we don't have anything else though. I do want to make this a check for a real version string, not just a string.

for (int i = 0; i < clients.size(); i++) {
JsonObject client = (JsonObject) clients.get(i);
String status = client.getString("status");
Assert.assertTrue(status,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use Hamcrest's org.hamcrest.collection.IsArrayContaining so the invalid value is shown in the failure message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


import org.junit.Test;

public class MavenCoordinatesTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need some tests for equals()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@loosebazooka
Copy link
Contributor

loosebazooka commented Aug 25, 2017

The PR says it's expanding JSON test coverages but makes changes to a non-test class? Is there more going on here?

@elharo
Copy link
Contributor Author

elharo commented Aug 25, 2017

We needed MavenCoordinates for the tests, or did at one point. Now I'm not so sure. I expect there'll be some libraries for processing the metadata, though I'm still not sure which piece swill land here and which in the IDE repos.

@loosebazooka
Copy link
Contributor

If it's only being used for tests, can it be in the src/test/java directory instead?

@elharo
Copy link
Contributor Author

elharo commented Aug 25, 2017

reverted MavenCoordinates now; it can come back later if needed


private static final String[] statuses = {"alpha", "beta", "GA"};

private static void verifyApi(JsonObject api) throws URISyntaxException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : would using assertApi instead of verifyApi clarify that the intention of the method is to make assertions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

new URI(api.getString("documentation"));
if (api.getString("icon") != null) {
new URI(api.getString("icon"));
Map<String, String> map = new HashMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name of map maybe can be more descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

@Test
public void testMavenCoordinates() throws FileNotFoundException, URISyntaxException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be named testMavenCoordinate_fileIsValid or something? It's hard for me to tell (since I didn't really look at the previous CL) what this test is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@codecov
Copy link

codecov bot commented Aug 25, 2017

Codecov Report

Merging #443 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #443   +/-   ##
=======================================
  Coverage   66.28%   66.28%           
=======================================
  Files          67       67           
  Lines        1815     1815           
  Branches      281      281           
=======================================
  Hits         1203     1203           
  Misses        489      489           
  Partials      123      123

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a6ec35c...05e0d09. Read the comment docs.

@elharo elharo changed the title expand JSON test coverage expand JSON test coverage; add datastore and BigQuery Aug 28, 2017
@elharo elharo changed the title expand JSON test coverage; add datastore and BigQuery expand JSON test coverage; add datastore and cloud storage Aug 28, 2017
"language":"java",
"site":"https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-install-java",
"apireference":"https://googlecloudplatform.github.io/google-cloud-java/0.22.0/apidocs/com/google/cloud/bigquery/package-summary.html",
"version" : "0.22.0",
"apireference":"https://googlecloudplatform.github.io/google-cloud-java/latest/apidocs/com/google/cloud/bigquery/package-summary.html",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be clearer as a language-specific field called javadoc?
Oh, actually we should have a javadoc field for programmatic access (e.g., Eclipse javadoc hovers) as well as a the more human-meaningful API starting point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would the difference be. For example, what javadoc URL would Eclipse need here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I try setting the Javadoc URL for a jar to this URL (right-click on a jar, like a bundle in the Plug-in Dependencies, and select Javadoc Location, and set as a URL), Eclipse shown an error:
screen shot 2017-08-28 at 4 32 01 pm

The java docs have a specific layout, as does the HTML. So Eclipse is able to find and parse out the appropriate Javadoc to be shown in a hover.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make that work, I think we first need to get google-cloud-java to publish individual javadoc for each API. The file it's looking for is at

https://googlecloudplatform.github.io/google-cloud-java/latest/apidocs/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably pull IDE readable source and javadoc jars from Maven Central rather than calling them out as a separate artifact.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to @elharo 's comment - then the javadoc and source will actually match the classes that the user is using.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CT for IntelliJ plans to expose these links to the end user so it needs human browsable URLs.

The links to the Maven source/javadoc jars don't need to be explicitly included here because they can be derived from the Maven coordinates.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

"language":"java",
"site":"https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-install-java",
"apireference":"https://googlecloudplatform.github.io/google-cloud-java/0.22.0/apidocs/com/google/cloud/bigquery/package-summary.html",
"version" : "0.22.0",
"apireference":"https://googlecloudplatform.github.io/google-cloud-java/latest/apidocs/com/google/cloud/bigquery/package-summary.html",
"infotip":"The com.google.cloud.bigquery packages",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be useful to encode in the metadata to enable UI discovery (e.g., a quick-fix on unresolved symbols)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate? I'm not sure exactly what you're proposing here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expressing this as:

"javaPackages":["com.google.cloud.bigquery", "com.google.cloud.bigquery.**"],

For example, PDE contributes a quick-fix to suggesting adding an Import-Package or Require-Bundle on an unresolved symbol that is found in a bundle:

screen shot 2017-08-28 at 4 22 18 pm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be something different. This is human readable text for the infotip on the library.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have this in a machine readable format too for the tooling reasons above.

Maybe it would help to add additional information here. For example, there are sometimes alpha versions of libraries that users may want to try. Or if this is the Google API Client library, we could add a pointer to the Google Client library?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. How do we tell Eclipse about our packages when adding a library?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd have a quick-fix on an unresolved symbol like PDE's quick-fix. Our quick-fix would iterate on the library definitions to see if it can find a match.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, ping on this request too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"name": "Google Cloud Datastore",
"documentation": "https://cloud.google.com/datastore/docs/reference/libraries",
"description":"Google Cloud Datastore is a NoSQL key-value database built for automatic scaling.",
"transport": "http",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Should transport be an array? What do we do for libraries that support both http and grpc?
  • Shouldn't this really be in the clients section? We may have libraries that just use the http REST APIs, even though the API supports both

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do any libraries support more than one transport? let me check with the api team.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still waiting for a reply but the docs do say, "Clients in this repository use either HTTP or gRPC for the transport layer. The README of each client documents the transport layer the client uses."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stepping back, what will we do with this information? Are we going to use it as a filter — e.g., if grpc then cannot be used on AESv7?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is better to encode this platform-compatibility knowledge into the consumers of this API, or to make it explicit in a compatibility/platform section? I lean towards the latter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That brings us back to where we were earlier with defining in this file all the possible platforms, and it all resolves to the transport anyway. For now, I'm inclined not to encode platforms. We can add those later if we need them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have turned this into an array though.

{
"name":"Google Cloud Storage Client Library for Java",
"language":"java",
"site":"https://cloud.google.com/storage/docs/reference/libraries#client-libraries-install-java",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the #using_the_client_library section be more appropriate, since the user will be using the consuming UI to automate the installation of this library?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I really wanted was the entire page, but that won't pick up Java as opposed to Python. This is the nearest link to the top.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me file a bug requesting a URL for the whole page.

((JsonObject) api.getJsonArray("clients").get(0)).getJsonObject("mavenCoordinates");
String mavenCoordinates =
coordinates.getString("groupId") + ":" + coordinates.getString("artifactId");
if (apiCoordinates.containsValue(mavenCoordinates)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be ok to provide different versions of an API library, shouldn't it? E.g., Java libraries for BigQuery 1.0.0 vs 2.0.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would have a different group or artifact ID. I don't think we want both 1.3.0 and 1.4.0.

"site":"https://cloud.google.com/datastore/docs/reference/libraries#client-libraries-install-java",
"apireference":"https://googlecloudplatform.github.io/google-cloud-java/latest/apidocs/index.html?com/google/cloud/datastore/package-summary.html",
"infotip":"The com.google.cloud.datastore packages",
"status" : "GA",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think releaseLevel would be a more accurate description of the Alpha/Beta/GA values

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wikipedia seems to call this a "stage" though I can't say I've heard that before: https://en.wikipedia.org/wiki/Software_release_life_cycle#Stages_of_development

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like "launch stage" is actually the terminology used by Google Cloud Platform: https://cloud.google.com/terms/launch-stages

However, we have to keep in mind that the release level of client libraries will lag behind the service.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could offer separate statuses for the API and the client library. This one is specific to the client library. Meanwhile I'll change this to launchStage.

"mavenCoordinates" : {
"groupId" : "com.google.cloud",
"artifactId" : "google-cloud-datastore",
"version" : "1.4.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this version have to be updated with every google-cloud-java release?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course clients do have the option to ignore the version here and query Maven central for the latest release version. CT4E contains code to do this.

"language":"java",
"site":"https://cloud.google.com/bigquery/docs/reference/libraries#client-libraries-install-java",
"apireference":"https://googlecloudplatform.github.io/google-cloud-java/0.22.0/apidocs/com/google/cloud/bigquery/package-summary.html",
"version" : "0.22.0",
"apireference":"https://googlecloudplatform.github.io/google-cloud-java/latest/apidocs/com/google/cloud/bigquery/package-summary.html",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

"name": "Google Cloud Storage",
"documentation": "https://cloud.google.com/storage/docs/reference/libraries",
"description":"Unified BLOB storage for developers and enterprises, from live data serving to data analytics/ML to data archiving.",
"transport": ["http"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pluralize transports? since we have clients and mavenCoordinates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@elharo
Copy link
Contributor Author

elharo commented Sep 5, 2017

Pinging everyone. Are there any final blockers that prevent us from checking this in and moving forward with the rest of the google-cloud-java APIs?

We can easily add additional content later. Changing or removing existing fields should be done here if possible.

If not, it needs an approval.

Copy link
Contributor Author

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping ping ping

Copy link
Contributor

@loosebazooka loosebazooka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might also be a good time to begin the process of separating out our plugin support libraries.

Copy link
Member

@briandealwis briandealwis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too.

@elharo elharo merged commit 8193135 into master Sep 8, 2017
@elharo elharo deleted the metadata branch September 8, 2017 16:53
JoeWang1127 pushed a commit that referenced this pull request Nov 29, 2023
* expand JSON test coverage

* add test for equals

* hamcrest

* redundant assert removed

* fix loop

* fix loop

* regex versions

* don't make repo a corrdinate

* type to packaging

* verify group ID artifact ID

* checkstyle fixes

* revert metadata for now

* code review

* add datastore api

* toArray

* GCS

* make transport an array

* make transport an array

* launchStage

* pluralize transports

* pluralize transports

* add packages
JoeWang1127 pushed a commit that referenced this pull request Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants