Page MenuHomePhabricator

Increase coverage to 70%
ClosedPublic

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

Details

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 692
Build 692: arc lint + arc unit

Event Timeline

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
104

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

WyldBot requested changes to this revision.Jul 2 2019, 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.Jul 2 2019, 8:23 PM
src/test/java/net/wildfyre/posts/PostTest.java
64

Oops. My bad. I'll remove tomorrow

  • Remove extraneous System.out.println
CLOVIS requested changes to this revision.Jul 3 2019, 11:57 AM

After these it'll be OK for me

src/main/java/net/wildfyre/posts/Draft.java
223 ↗(On Diff #958)

Why do you get it raw here?

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

I believe you could use:

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

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

Replace by:

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

This revision now requires changes to proceed.Jul 3 2019, 11:57 AM
Hackintosh5 added inline comments.
src/main/java/net/wildfyre/posts/Draft.java
223 ↗(On Diff #958)

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
71

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

All resolved.

src/main/java/net/wildfyre/posts/PostData.java
111
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
71
> 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.
CLOVIS added inline comments.
src/main/java/net/wildfyre/posts/Draft.java
223 ↗(On Diff #958)

OK

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

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

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

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

This revision now requires review to proceed.Jul 3 2019, 1:33 PM
This revision is now accepted and ready to land.Jul 3 2019, 1:37 PM