-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
348 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
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
32 changes: 32 additions & 0 deletions
32
...ava/com/avojak/webapp/aws/p2/repository/webapp/configuration/WebappConfigurationTest.java
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.avojak.webapp.aws.p2.repository.webapp.configuration; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
/** | ||
* Test class for {@link WebappConfiguration}. | ||
*/ | ||
public class WebappConfigurationTest { | ||
|
||
private WebappConfiguration configuration; | ||
|
||
@Before | ||
public void setup() { | ||
configuration = new WebappConfiguration(); | ||
ReflectionTestUtils.setField(configuration, "brandName", "Mock Brand"); | ||
ReflectionTestUtils.setField(configuration, "brandIcon", "mock.icon"); | ||
ReflectionTestUtils.setField(configuration, "brandFavicon", "mock.favicon"); | ||
ReflectionTestUtils.setField(configuration, "customDomain", "mock.domain"); | ||
ReflectionTestUtils.setField(configuration, "welcomeMessage", "Mock welcome"); | ||
ReflectionTestUtils.setField(configuration, "bucketName", "mock-bucket"); | ||
} | ||
|
||
@Test | ||
public void testWebappProperties() { | ||
assertNotNull(configuration.webappProperties()); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...t/java/com/avojak/webapp/aws/p2/repository/webapp/configuration/WebappPropertiesTest.java
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.avojak.webapp.aws.p2.repository.webapp.configuration; | ||
|
||
import nl.jqno.equalsverifier.EqualsVerifier; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Test class for {@link WebappProperties}. | ||
*/ | ||
public class WebappPropertiesTest { | ||
|
||
@Test | ||
public void testGetters() { | ||
final WebappProperties properties = new WebappProperties("brandName", "brandIcon", "brandFavicon", | ||
"customDomain", "welcomeMessage", "bucketName"); | ||
assertEquals("brandName", properties.getBrandName()); | ||
assertEquals("brandIcon", properties.getBrandIcon()); | ||
assertEquals("brandFavicon", properties.getBrandFavicon()); | ||
assertEquals("customDomain", properties.getCustomDomain()); | ||
assertEquals("welcomeMessage", properties.getWelcomeMessage()); | ||
assertEquals("bucketName", properties.getBucketName()); | ||
} | ||
|
||
@Test | ||
public void testEquals() { | ||
EqualsVerifier.forClass(WebappProperties.class).verify(); | ||
} | ||
|
||
} |
89 changes: 89 additions & 0 deletions
89
...c/test/java/com/avojak/webapp/aws/p2/repository/webapp/controller/DataControllerTest.java
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.avojak.webapp.aws.p2.repository.webapp.controller; | ||
|
||
import com.avojak.webapp.aws.p2.repository.model.Qualifier; | ||
import com.avojak.webapp.aws.p2.repository.model.project.Project; | ||
import com.avojak.webapp.aws.p2.repository.service.DataService; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* Test class for {@link DataController}. | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
public class DataControllerTest { | ||
|
||
@Mock | ||
private DataService dataService; | ||
|
||
@Mock | ||
private HttpServletRequest request; | ||
|
||
private DataController controller; | ||
|
||
@Before | ||
public void setup() { | ||
controller = new DataController(dataService); | ||
} | ||
|
||
@Test(expected = NullPointerException.class) | ||
public void testConstructor_NullDataService() { | ||
new DataController(null); | ||
} | ||
|
||
@Test | ||
public void testGetResource() { | ||
final String requestURI = "content/mock-project/releases/1.0.0"; | ||
when(request.getRequestURI()).thenReturn(requestURI); | ||
final String project = "mock-project"; | ||
final String qualifier = "releases"; | ||
final String version = "1.0.0"; | ||
final Resource resource = mock(Resource.class); | ||
when(dataService.getResource("mock-project/releases/1.0.0", project, Qualifier.RELEASE, version)) | ||
.thenReturn(Optional.of(resource)); | ||
|
||
final ResponseEntity<Resource> response = controller.getResource(project, qualifier, version, request); | ||
assertEquals(200, response.getStatusCodeValue()); | ||
assertEquals(resource, response.getBody()); | ||
} | ||
|
||
@Test | ||
public void testGetResource_NotFound() { | ||
final String requestURI = "content/mock-project/releases/1.0.0"; | ||
when(request.getRequestURI()).thenReturn(requestURI); | ||
final String project = "mock-project"; | ||
final String qualifier = "releases"; | ||
final String version = "1.0.0"; | ||
when(dataService.getResource("mock-project/releases/1.0.0", project, Qualifier.RELEASE, version)) | ||
.thenReturn(Optional.empty()); | ||
|
||
final ResponseEntity<Resource> response = controller.getResource(project, qualifier, version, request); | ||
assertEquals(404, response.getStatusCodeValue()); | ||
} | ||
|
||
@Test | ||
public void testGetProjects() { | ||
final List<Project> projects = new ArrayList<>(); | ||
when(dataService.getProjects()).thenReturn(projects); | ||
|
||
final ResponseEntity<Collection<Project>> response = controller.getProjects(); | ||
|
||
assertEquals(200, response.getStatusCodeValue()); | ||
assertEquals(projects, response.getBody()); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...st/java/com/avojak/webapp/aws/p2/repository/webapp/controller/RedirectControllerTest.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.avojak.webapp.aws.p2.repository.webapp.controller; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Test class for {@link RedirectController}. | ||
*/ | ||
public class RedirectControllerTest { | ||
|
||
@Test | ||
public void testRedirect() { | ||
assertEquals("redirect:/browse", new RedirectController().redirectToBrowse()); | ||
} | ||
|
||
} |
Oops, something went wrong.