-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from devindi/test_fix
- Loading branch information
Showing
1 changed file
with
2 additions
and
73 deletions.
There are no files selected for viewing
75 changes: 2 additions & 73 deletions
75
...oad/src/test/groovy/com/devindi/gradle/diawi/task/internal/UploadParamsFactoryTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,30 @@ | ||
package com.devindi.gradle.diawi.task.internal | ||
|
||
import com.devindi.gradle.diawi.dsl.DiawiUploadExtension | ||
import org.gradle.api.logging.Logger | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
import static org.mockito.ArgumentMatchers.any | ||
import static org.mockito.Mockito.* | ||
|
||
@SuppressWarnings("GrDeprecatedAPIUsage") | ||
class UploadParamsFactoryTest { | ||
|
||
def loggerMock = mock(Logger.class) | ||
def factory = new UploadParamsFactory(loggerMock) | ||
|
||
@Test | ||
void callbackUrlNewDsl() { | ||
DiawiUploadExtension extension = createExtension() | ||
extension.callback.url = "http://example.com" | ||
|
||
def params = factory.createParams(extension) | ||
|
||
Assert.assertEquals("http://example.com", params.callbackUrl) | ||
verifyNoMoreInteractions(loggerMock) | ||
} | ||
|
||
@Test | ||
void callbackUrlOldDsl() { | ||
DiawiUploadExtension extension = createExtension() | ||
extension.callbackUrl = "http://example.com" | ||
|
||
def params = factory.createParams(extension) | ||
def params = UploadParamsFactory.createParams(extension) | ||
|
||
Assert.assertEquals("http://example.com", params.callbackUrl) | ||
verify(loggerMock).warn(any(String.class)) | ||
} | ||
|
||
@Test | ||
void newDslPreferredUrl() { | ||
DiawiUploadExtension extension = createExtension() | ||
extension.callbackUrl = "http://old.example.com" | ||
extension.callback.url = "http://new.example.com" | ||
|
||
def params = factory.createParams(extension) | ||
|
||
Assert.assertEquals("http://new.example.com", params.callbackUrl) | ||
verify(loggerMock).warn(any(String.class)) | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
void tokenRequiredException() { | ||
DiawiUploadExtension extension = new DiawiUploadExtension() | ||
|
||
factory.createParams(extension) | ||
} | ||
|
||
@Test | ||
void callbackEmailNewDsl() { | ||
DiawiUploadExtension extension = createExtension() | ||
extension.callback.emails = ["[email protected]"] | ||
|
||
def params = factory.createParams(extension) | ||
def params = UploadParamsFactory.createParams(extension) | ||
|
||
Assert.assertEquals("[email protected]", params.callbackEmails) | ||
verifyNoMoreInteractions(loggerMock) | ||
} | ||
|
||
@Test | ||
void callbackEmailOldDsl() { | ||
DiawiUploadExtension extension = createExtension() | ||
extension.callbackEmail = "[email protected]" | ||
|
||
def params = factory.createParams(extension) | ||
|
||
Assert.assertEquals("[email protected]", params.callbackEmails) | ||
verify(loggerMock).warn(any(String.class)) | ||
} | ||
|
||
@Test | ||
void newDslPreferredEmail() { | ||
DiawiUploadExtension extension = createExtension() | ||
extension.callbackEmail = ["[email protected]"] | ||
extension.callback.emails = ["[email protected]"] | ||
|
||
def params = factory.createParams(extension) | ||
|
||
Assert.assertEquals("[email protected]", params.callbackEmails) | ||
verify(loggerMock).warn(any(String.class)) | ||
} | ||
|
||
@Test | ||
void noLogsForEmpty() { | ||
DiawiUploadExtension extension = createExtension() | ||
|
||
factory.createParams(extension) | ||
|
||
verifyNoMoreInteractions(loggerMock) | ||
} | ||
|
||
private static def createExtension() { | ||
|