Fix p18 issue For an item with P18 item, do not add another one (#3527)

* Add p18value variable to contrib

* set place.pic to candidate contribution

* Add p18 value to contrib

* Passes p18 value to wikidata upload service

* Checks if pic parameter of the wikidata item is empty or not. If not, it does not overrides the existing image, it is just a regular commons upload.

* Make public var private

* Make current tests pass

* Add test case for p18 value is not empty

* Fix wrong log message

* Add nonnul annotation and fix method javadoc
This commit is contained in:
neslihanturan 2020-03-17 12:35:21 +02:00 committed by GitHub
parent bdb61dfda6
commit e5d5a7af92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 10 deletions

View file

@ -34,13 +34,19 @@ class WikidataEditServiceTest {
@Test
fun noClaimsWhenEntityIdIsNull() {
wikidataEditService!!.createClaimWithLogging(null, "Test.jpg")
wikidataEditService!!.createClaimWithLogging(null, "Test.jpg","")
verifyZeroInteractions(wikidataClient!!)
}
@Test
fun noClaimsWhenFileNameIsNull() {
wikidataEditService!!.createClaimWithLogging("Q1", null)
wikidataEditService!!.createClaimWithLogging("Q1", null,"")
verifyZeroInteractions(wikidataClient!!)
}
@Test
fun noClaimsWhenP18IsNotEmpty() {
wikidataEditService!!.createClaimWithLogging("Q1", "Test.jpg","Previous.jpg")
verifyZeroInteractions(wikidataClient!!)
}
@ -48,7 +54,7 @@ class WikidataEditServiceTest {
fun noClaimsWhenLocationIsNotCorrect() {
`when`(directKvStore!!.getBoolean("Picture_Has_Correct_Location", true))
.thenReturn(false)
wikidataEditService!!.createClaimWithLogging("Q1", "Test.jpg")
wikidataEditService!!.createClaimWithLogging("Q1", "Test.jpg","")
verifyZeroInteractions(wikidataClient!!)
}
@ -60,7 +66,7 @@ class WikidataEditServiceTest {
.thenReturn(Observable.just(1L))
`when`(wikidataClient!!.addEditTag(anyLong(), ArgumentMatchers.anyString(), ArgumentMatchers.anyString()))
.thenReturn(Observable.just(mock(AddEditTagResponse::class.java)))
wikidataEditService!!.createClaimWithLogging("Q1", "Test.jpg")
wikidataEditService!!.createClaimWithLogging("Q1", "Test.jpg","")
verify(wikidataClient!!, times(1))
.createClaim(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())
}