-
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
9 changed files
with
420 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package edu.tamu.app.model; | ||
|
||
import java.util.List; | ||
|
||
public class Card { | ||
|
||
// Identifier for the card | ||
private final String name; | ||
|
||
// Title displayed above the card body | ||
private final String title; | ||
|
||
private final String body; | ||
|
||
private final String estimate; | ||
|
||
private final List<Member> members; | ||
|
||
private final String status; | ||
|
||
private final String type; | ||
|
||
public Card(String name, String title, String body, String estimate, List<Member> members, String status, String type) { | ||
this.name = name; | ||
this.title = title; | ||
this.body = body; | ||
this.estimate = estimate; | ||
this.members = members; | ||
this.status = status; | ||
this.type = type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public String getBody() { | ||
return body; | ||
} | ||
|
||
public String getEstimate() { | ||
return estimate; | ||
} | ||
|
||
public List<Member> getMembers() { | ||
return members; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
} |
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,22 @@ | ||
package edu.tamu.app.model; | ||
|
||
public class Member { | ||
|
||
private final String name; | ||
|
||
private final String avatarUrl; | ||
|
||
public Member(String name, String avatarUrl) { | ||
this.name = name; | ||
this.avatarUrl = avatarUrl; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getAvatarUrl() { | ||
return avatarUrl; | ||
} | ||
|
||
} |
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,38 @@ | ||
package edu.tamu.app.model; | ||
|
||
import java.util.List; | ||
|
||
public class Sprint { | ||
|
||
private final String identifier; | ||
|
||
private final String name; | ||
|
||
private final String projectName; | ||
|
||
private final List<Card> cards; | ||
|
||
public Sprint(String identifier, String name, String projectName, List<Card> cards) { | ||
this.identifier = identifier; | ||
this.name = name; | ||
this.projectName = projectName; | ||
this.cards = cards; | ||
} | ||
|
||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getProjectName() { | ||
return projectName; | ||
} | ||
|
||
public List<Card> getCards() { | ||
return cards; | ||
} | ||
|
||
} |
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
62 changes: 62 additions & 0 deletions
62
src/test/java/edu/tamu/app/cache/RemoteProjectsCacheTest.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,62 @@ | ||
package edu.tamu.app.cache; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import edu.tamu.app.cache.model.RemoteProject; | ||
|
||
@RunWith(SpringRunner.class) | ||
public class RemoteProjectsCacheTest { | ||
|
||
@Test | ||
public void testNewRemoteProjectsCache() { | ||
RemoteProjectsCache cache = new RemoteProjectsCache(); | ||
assertNotNull("New remote project cache was not created!", cache); | ||
assertNotNull("New remote project cache remoteProjects were not created!", cache.get()); | ||
} | ||
|
||
@Test | ||
public void testSetCache() { | ||
RemoteProjectsCache cache = new RemoteProjectsCache(); | ||
assertTrue("Cached remote projects was not empty!", cache.get().isEmpty()); | ||
Map<Long, List<RemoteProject>> remoteProjectMap = new HashMap<Long, List<RemoteProject>>(); | ||
List<RemoteProject> remoteProjects = new ArrayList<RemoteProject>(); | ||
remoteProjects.add(getMockRemoteProject()); | ||
remoteProjectMap.put(1L, remoteProjects); | ||
cache.set(remoteProjectMap); | ||
assertFalse("Cached remoteProjects was empty!", cache.get().isEmpty()); | ||
} | ||
|
||
@Test | ||
public void testGetCache() { | ||
RemoteProjectsCache cache = new RemoteProjectsCache(); | ||
Map<Long, List<RemoteProject>> remoteProjectMap = new HashMap<Long, List<RemoteProject>>(); | ||
List<RemoteProject> remoteProjects = new ArrayList<RemoteProject>(); | ||
remoteProjects.add(getMockRemoteProject()); | ||
remoteProjectMap.put(1L, remoteProjects); | ||
cache.set(remoteProjectMap); | ||
Map<Long, List<RemoteProject>> remoteProjectsCache = cache.get(); | ||
assertFalse("Cached remote projects was empty!", remoteProjectsCache.isEmpty()); | ||
assertEquals("Cached remote projects had incorrect number of remote projects!", 1, remoteProjectsCache.size()); | ||
assertEquals("Cached remote projects did not have expected remote projects for a given remote project manager!", 1, remoteProjectsCache.get(1L).size()); | ||
|
||
assertEquals("Cached remote project had incorrect id!", "0001", remoteProjectsCache.get(1L).get(0).getScopeId()); | ||
assertEquals("Cached remote project had incorrect name!", "Remote Project 1", remoteProjectsCache.get(1L).get(0).getName()); | ||
} | ||
|
||
private RemoteProject getMockRemoteProject() { | ||
return new RemoteProject("0001", "Remote Project 1"); | ||
} | ||
|
||
} |
85 changes: 85 additions & 0 deletions
85
src/test/java/edu/tamu/app/cache/controller/RemoteProjectsCacheControllerTest.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,85 @@ | ||
package edu.tamu.app.cache.controller; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import edu.tamu.app.cache.model.RemoteProject; | ||
import edu.tamu.app.cache.service.RemoteProjectsScheduledCacheService; | ||
import edu.tamu.weaver.response.ApiResponse; | ||
import edu.tamu.weaver.response.ApiStatus; | ||
|
||
@RunWith(SpringRunner.class) | ||
public class RemoteProjectsCacheControllerTest { | ||
|
||
@Mock | ||
private RemoteProjectsScheduledCacheService remoteProjectsScheduledCacheService; | ||
|
||
@InjectMocks | ||
private RemoteProjectsCacheController remoteProjectsCacheController; | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
MockitoAnnotations.initMocks(this); | ||
when(remoteProjectsScheduledCacheService.get()).thenReturn(getMockRemoteProjectsCache()); | ||
} | ||
|
||
@Test | ||
@SuppressWarnings("unchecked") | ||
public void testGet() { | ||
ApiResponse response = remoteProjectsCacheController.get(); | ||
assertNotNull("Reponse was null!", response); | ||
assertEquals("Reponse was not successfull!", ApiStatus.SUCCESS, response.getMeta().getStatus()); | ||
|
||
assertNotNull("Reponse payload did not have expected property!", response.getPayload().get("HashMap")); | ||
assertRemoteProjects((Map<Long, List<RemoteProject>>) response.getPayload().get("HashMap")); | ||
} | ||
|
||
@Test | ||
public void testUpdate() { | ||
ApiResponse response = remoteProjectsCacheController.update(); | ||
assertNotNull(response); | ||
assertEquals(ApiStatus.SUCCESS, response.getMeta().getStatus()); | ||
verify(remoteProjectsScheduledCacheService, times(1)).update(); | ||
verify(remoteProjectsScheduledCacheService, times(1)).broadcast(); | ||
} | ||
|
||
private void assertRemoteProjects(Map<Long, List<RemoteProject>> remoteProjectsCache) { | ||
assertFalse(remoteProjectsCache.isEmpty()); | ||
assertEquals(1, remoteProjectsCache.size()); | ||
List<RemoteProject> remoteProjects = remoteProjectsCache.get(1L); | ||
assertFalse(remoteProjects.isEmpty()); | ||
assertEquals(1, remoteProjects.size()); | ||
assertEquals("0001", remoteProjects.get(0).getScopeId()); | ||
assertEquals("Remote Project 1", remoteProjects.get(0).getName()); | ||
} | ||
|
||
private Map<Long, List<RemoteProject>> getMockRemoteProjectsCache() { | ||
Map<Long, List<RemoteProject>> remoteProjectCache = new HashMap<Long, List<RemoteProject>>(); | ||
List<RemoteProject> remoteProjects = new ArrayList<RemoteProject>(); | ||
remoteProjects.add(getMockRemoteProject()); | ||
remoteProjectCache.put(1L, remoteProjects); | ||
return remoteProjectCache; | ||
} | ||
|
||
private RemoteProject getMockRemoteProject() { | ||
return new RemoteProject("0001", "Remote Project 1"); | ||
} | ||
|
||
} |
Oops, something went wrong.