Page MenuHomePhabricator

Increase coverage to 70%
AcceptedPublic

Authored by Hackintosh5 on Tue, Jul 2, 11:08 AM.

Details

Reviewers
CLOVIS
WyldBot
Summary

Add tests and increase minimum coverage to 70%
Depends on D255

Test Plan

Run tests and check jacoco passes coverage requirements

Diff Detail

Repository
rLIBWFJVA WildFyre Java Libary
Branch
master
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 697
Build 697: arc lint + arc unit

Event Timeline

Hackintosh5 created this revision.Tue, Jul 2, 11:08 AM
Hackintosh5 added inline comments.Tue, Jul 2, 12:10 PM
src/main/java/net/wildfyre/posts/PostData.java
149

This was causing an NPE for me, in case you're wondering why. Using addAll fixed it. Don't ask.

419

Putting a null image causes a server error.

src/test/java/net/wildfyre/posts/PostTest.java
102

We can't test this, because the server saves it and there's no Post.delete()

WyldBot requested changes to this revision.Tue, Jul 2, 8:23 PM
WyldBot added inline comments.
src/test/java/net/wildfyre/posts/PostTest.java
64

Suppose to have a console here?

This revision now requires changes to proceed.Tue, Jul 2, 8:23 PM
Hackintosh5 added inline comments.Tue, Jul 2, 8:39 PM
src/test/java/net/wildfyre/posts/PostTest.java
64

Oops. My bad. I'll remove tomorrow

Hackintosh5 updated this revision to Diff 958.Wed, Jul 3, 7:27 AM
  • Remove extraneous System.out.println
CLOVIS requested changes to this revision.Wed, Jul 3, 11:57 AM

After these it'll be OK for me

src/main/java/net/wildfyre/posts/Draft.java
223

Why do you get it raw here?

src/main/java/net/wildfyre/posts/PostData.java
112

I believe you could use:

isActive = json.getBoolean("active", true)

src/test/java/net/wildfyre/posts/PostTest.java
72

Replace by:

data["id"] = c1.ID()

This revision now requires changes to proceed.Wed, Jul 3, 11:57 AM
Hackintosh5 marked an inline comment as done.Wed, Jul 3, 12:03 PM
Hackintosh5 added inline comments.
src/main/java/net/wildfyre/posts/Draft.java
223

Server returns 204 No Content
As the name says, there's No Content. A valid JSON string must include a root element, so getJson() fails with a JSON parsing error (unexpected EOF).

src/test/java/net/wildfyre/posts/PostTest.java
72

This isn't a Kotlin test. Are you sure that works in Java? Iirc it doesn't, but it's been a while.

Hackintosh5 marked 4 inline comments as done.Wed, Jul 3, 12:10 PM

All resolved.

src/main/java/net/wildfyre/posts/PostData.java
112
java.lang.UnsupportedOperationException: Not a boolean: null
	at com.eclipsesource.json.JsonValue.asBoolean(JsonValue.java:396)
	at com.eclipsesource.json.JsonLiteral.asBoolean(JsonLiteral.java:79)
	at com.eclipsesource.json.JsonObject.getBoolean(JsonObject.java:656)
	at net.wildfyre.posts.PostData.update(PostData.java:109)
	at net.wildfyre.posts.Draft.saveFirstTime(Draft.java:169)
	at net.wildfyre.posts.Draft.save(Draft.java:155)
	at net.wildfyre.posts.PostTest.createDraft(PostTest.java:96)

With your code

src/test/java/net/wildfyre/posts/PostTest.java
72
> Task :compileTestJava FAILED
/home/penn/libwf-java/src/test/java/net/wildfyre/posts/PostTest.java:72: error: incompatible types: String cannot be converted to int
        data["id"] = c1.ID();
             ^
/home/penn/libwf-java/src/test/java/net/wildfyre/posts/PostTest.java:72: error: array required, but JsonObject found
        data["id"] = c1.ID();
            ^
2 errors

FAILURE: Build failed with an exception.
Hackintosh5 marked an inline comment as done.Wed, Jul 3, 12:53 PM
CLOVIS accepted this revision.Wed, Jul 3, 1:33 PM
CLOVIS added inline comments.
src/main/java/net/wildfyre/posts/Draft.java
223

OK

src/main/java/net/wildfyre/posts/PostData.java
112

That means the server sends active: null... welp, keep your code then

src/test/java/net/wildfyre/posts/PostTest.java
72

Oh I forgot that part wasn't translated yet. My bad.

This revision now requires review to proceed.Wed, Jul 3, 1:33 PM
WyldBot accepted this revision.Wed, Jul 3, 1:37 PM
This revision is now accepted and ready to land.Wed, Jul 3, 1:37 PM
Hackintosh5 marked 3 inline comments as done.Wed, Jul 3, 1:39 PM