target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void testAccept() throws Exception { int result = reviewService.accept(1L, "testuser", new ReviewRequest("local_test", "/test/sub1", 0, 0, ReviewStatus.ACCEPTED.getValue(), "testuser", "testuser", new Date(), Action.UPDATE.getValue())); Assert.assertNotEquals(0, result); }
@Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); } }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); } }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { @Transactional public int accept(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } switch (Action.get(reviewRequest.getAction())) { case DELETE: nodeBiz.delete(reviewRequest.getCluster(), reviewRequest.getPath()); break; case ADD: logger.error("Add action doesn't need review, id:{}", id); break; case UPDATE: nodeBiz.update(reviewRequest.getCluster(), reviewRequest.getPath(), reviewRequest.getNewSnapshotContent(), reviewRequest.getNewSnapshot()); break; default: logger.error("Action value not corrected, id:{}", id); break; } Stat stat = nodeDAO.getStat(reviewRequest.getCluster(), reviewRequest.getPath(), true); logger.info("Accepted review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.ACCEPTED.getDescription()); return this.update(ReviewStatus.ACCEPTED, id, reviewer, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
@Test public void testRefuse() throws Exception { int result = reviewService.refuse(1L, "testuser", new ReviewRequest("local_test", "/test/sub1", 0, 0, ReviewStatus.ACCEPTED.getValue(), "testuser", "testuser", new Date(), Action.UPDATE.getValue())); Assert.assertNotEquals(0, result); }
@Transactional public int refuse(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } logger.info("Rejected review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.REJECTED.getDescription()); return this.update(ReviewStatus.REJECTED, id, reviewer, reviewRequest.getNewSnapshot(), ReviewUtil.DEFAULT_MTIME); }
ReviewService { @Transactional public int refuse(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } logger.info("Rejected review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.REJECTED.getDescription()); return this.update(ReviewStatus.REJECTED, id, reviewer, reviewRequest.getNewSnapshot(), ReviewUtil.DEFAULT_MTIME); } }
ReviewService { @Transactional public int refuse(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } logger.info("Rejected review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.REJECTED.getDescription()); return this.update(ReviewStatus.REJECTED, id, reviewer, reviewRequest.getNewSnapshot(), ReviewUtil.DEFAULT_MTIME); } }
ReviewService { @Transactional public int refuse(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } logger.info("Rejected review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.REJECTED.getDescription()); return this.update(ReviewStatus.REJECTED, id, reviewer, reviewRequest.getNewSnapshot(), ReviewUtil.DEFAULT_MTIME); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { @Transactional public int refuse(long id, String reviewer, ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } if (!teamBiz.isAboveRole(reviewRequest.getCluster(), reviewRequest.getPath(), Role.MASTER, reviewer)) { throw ShepherException.createNoAuthorizationException(); } logger.info("Rejected review request, reviewId={}, reviewer={}", id, reviewer); mailSenderFactory.getMailSender().noticeReview(reviewRequest.getCreator(), reviewer, reviewRequest.getPath(), reviewRequest.getCluster(), serverUrl + "/reviews/" + id, ReviewStatus.REJECTED.getDescription()); return this.update(ReviewStatus.REJECTED, id, reviewer, reviewRequest.getNewSnapshot(), ReviewUtil.DEFAULT_MTIME); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
@Test public void testGet() throws Exception { ReviewRequest reviewRequest = reviewService.get(1); Assert.assertNotNull(reviewRequest); }
public ReviewRequest get(long id) { return reviewBiz.get(id); }
ReviewService { public ReviewRequest get(long id) { return reviewBiz.get(id); } }
ReviewService { public ReviewRequest get(long id) { return reviewBiz.get(id); } }
ReviewService { public ReviewRequest get(long id) { return reviewBiz.get(id); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { public ReviewRequest get(long id) { return reviewBiz.get(id); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
@Test public void testRejectIfExpired() throws Exception { reviewService.rejectIfExpired(new ReviewRequest("local_test", "/test/sub1", 0, 0, ReviewStatus.ACCEPTED.getValue(), "testuser", "testuser", new Date(), Action.UPDATE.getValue())); }
@Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } }
ReviewService { @Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } } }
ReviewService { @Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } } }
ReviewService { @Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { @Transactional public void rejectIfExpired(ReviewRequest reviewRequest) throws ShepherException { if (reviewRequest == null) { throw ShepherException.createIllegalParameterException(); } Snapshot snapshot = snapshotBiz.get(reviewRequest.getNewSnapshot()); if (snapshot != null && reviewRequest.getReviewStatus() == ReviewStatus.NEW.getValue()) { Stat stat = nodeDAO.getStat(snapshot.getCluster(), snapshot.getPath(), true); if (stat == null || stat.getVersion() >= snapshot.getZkVersion()) { this.update(ReviewStatus.REJECTED, reviewRequest.getId(), ReviewUtil.DEFAULT_CREATOR, reviewRequest.getNewSnapshot(), stat == null ? ReviewUtil.DEFAULT_MTIME : stat.getMtime()); reviewRequest.setReviewStatus(ReviewStatus.REJECTED.getValue()); } } } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
@Test public void testDelete() throws Exception { int result = reviewService.delete(1); Assert.assertEquals(RESULT_OK, result); }
public int delete(long id) throws ShepherException { return reviewBiz.delete(id); }
ReviewService { public int delete(long id) throws ShepherException { return reviewBiz.delete(id); } }
ReviewService { public int delete(long id) throws ShepherException { return reviewBiz.delete(id); } }
ReviewService { public int delete(long id) throws ShepherException { return reviewBiz.delete(id); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
ReviewService { public int delete(long id) throws ShepherException { return reviewBiz.delete(id); } @Transactional long create(String cluster, String path, String data, User creator, Action action, ReviewStatus reviewStatus); @Transactional int update(ReviewStatus reviewStatus, long id, String reviewer, long snapshotId, long zkMtime); @Transactional int accept(long id, String reviewer, ReviewRequest reviewRequest); @Transactional int refuse(long id, String reviewer, ReviewRequest reviewRequest); ReviewRequest get(long id); @Transactional void rejectIfExpired(ReviewRequest reviewRequest); int delete(long id); }
@Test public void testGetByPath() throws Exception { String path = "/test/test2"; String cluster = "local_test"; int offset = 0; int limit = 20; List<Snapshot> snapshots = snapshotService.getByPath(path, cluster, offset, limit); Assert.assertNotNull(snapshots); Assert.assertEquals(2, snapshots.size()); }
public List<Snapshot> getByPath(String path, String cluster, int offset, int limit) throws ShepherException { return snapshotBiz.listByPath(path, cluster, offset, limit); }
SnapshotService { public List<Snapshot> getByPath(String path, String cluster, int offset, int limit) throws ShepherException { return snapshotBiz.listByPath(path, cluster, offset, limit); } }
SnapshotService { public List<Snapshot> getByPath(String path, String cluster, int offset, int limit) throws ShepherException { return snapshotBiz.listByPath(path, cluster, offset, limit); } }
SnapshotService { public List<Snapshot> getByPath(String path, String cluster, int offset, int limit) throws ShepherException { return snapshotBiz.listByPath(path, cluster, offset, limit); } List<Snapshot> getByPath(String path, String cluster, int offset, int limit); Snapshot getById(long id); }
SnapshotService { public List<Snapshot> getByPath(String path, String cluster, int offset, int limit) throws ShepherException { return snapshotBiz.listByPath(path, cluster, offset, limit); } List<Snapshot> getByPath(String path, String cluster, int offset, int limit); Snapshot getById(long id); }
@Test public void testGetById() throws Exception { Snapshot snapshot = snapshotService.getById(1); Assert.assertNotNull(snapshot); }
public Snapshot getById(long id) { return snapshotBiz.get(id); }
SnapshotService { public Snapshot getById(long id) { return snapshotBiz.get(id); } }
SnapshotService { public Snapshot getById(long id) { return snapshotBiz.get(id); } }
SnapshotService { public Snapshot getById(long id) { return snapshotBiz.get(id); } List<Snapshot> getByPath(String path, String cluster, int offset, int limit); Snapshot getById(long id); }
SnapshotService { public Snapshot getById(long id) { return snapshotBiz.get(id); } List<Snapshot> getByPath(String path, String cluster, int offset, int limit); Snapshot getById(long id); }
@Test public void testGetId() throws Exception { long id = 1; User user = userService.get(id); Assert.assertNotNull(user); Assert.assertEquals("banchuanyu", user.getName()); }
public User get(long id) { return userBiz.getById(id); }
UserService { public User get(long id) { return userBiz.getById(id); } }
UserService { public User get(long id) { return userBiz.getById(id); } }
UserService { public User get(long id) { return userBiz.getById(id); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
UserService { public User get(long id) { return userBiz.getById(id); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
@Test public void testGetName() throws Exception { String name = "banchuanyu"; User user = userService.get(name); Assert.assertNotNull(user); Assert.assertEquals(1, user.getId()); }
public User get(long id) { return userBiz.getById(id); }
UserService { public User get(long id) { return userBiz.getById(id); } }
UserService { public User get(long id) { return userBiz.getById(id); } }
UserService { public User get(long id) { return userBiz.getById(id); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
UserService { public User get(long id) { return userBiz.getById(id); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
@Test public void testGetStatForClusterPathReturnNullIfPathNotExists() throws Exception { Stat stat = nodeService.getStat("local_test", "/test", true); Assert.assertNotNull(stat); }
public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
NodeService { public Stat getStat(String cluster, String path) throws ShepherException { return this.getStat(cluster, path, true); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
@Test public void testCreate() throws Exception { String name = "test_user"; User user = userService.create(name); Assert.assertEquals(4, user.getId()); }
public User create(String name) throws ShepherException { return userBiz.create(name); }
UserService { public User create(String name) throws ShepherException { return userBiz.create(name); } }
UserService { public User create(String name) throws ShepherException { return userBiz.create(name); } }
UserService { public User create(String name) throws ShepherException { return userBiz.create(name); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
UserService { public User create(String name) throws ShepherException { return userBiz.create(name); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
@Test public void testCreateIfNotExist() throws Exception { String existedName = "banchuanyu"; User user = userService.createIfNotExist(existedName); Assert.assertEquals(1, user.getId()); String name = "test_user"; user = userService.createIfNotExist(name); Assert.assertNotNull(user); Assert.assertEquals(4, user.getId()); }
public User createIfNotExist(String name) throws ShepherException { User user = this.get(name); if (user == null) { user = this.create(name); } return user; }
UserService { public User createIfNotExist(String name) throws ShepherException { User user = this.get(name); if (user == null) { user = this.create(name); } return user; } }
UserService { public User createIfNotExist(String name) throws ShepherException { User user = this.get(name); if (user == null) { user = this.create(name); } return user; } }
UserService { public User createIfNotExist(String name) throws ShepherException { User user = this.get(name); if (user == null) { user = this.create(name); } return user; } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
UserService { public User createIfNotExist(String name) throws ShepherException { User user = this.get(name); if (user == null) { user = this.create(name); } return user; } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
@Test public void testListByTeams() throws Exception { Set<Long> teams = new HashSet<>(); teams.add(1L); teams.add(2L); List<User> users = userService.listByTeams(teams, Status.AGREE, Role.MEMBER); Assert.assertNotNull(users); Assert.assertEquals(3, users.size()); }
public List<User> listByTeams(Set<Long> teams, Status status, Role role) throws ShepherException { return userBiz.list(teams, status, role); }
UserService { public List<User> listByTeams(Set<Long> teams, Status status, Role role) throws ShepherException { return userBiz.list(teams, status, role); } }
UserService { public List<User> listByTeams(Set<Long> teams, Status status, Role role) throws ShepherException { return userBiz.list(teams, status, role); } }
UserService { public List<User> listByTeams(Set<Long> teams, Status status, Role role) throws ShepherException { return userBiz.list(teams, status, role); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
UserService { public List<User> listByTeams(Set<Long> teams, Status status, Role role) throws ShepherException { return userBiz.list(teams, status, role); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
@Test public void testListNamesByTeams() throws Exception { Set<Long> teams = new HashSet<>(); teams.add(1L); teams.add(2L); Set<String> names = userService.listNamesByTeams(teams, Status.AGREE, Role.MEMBER); Assert.assertNotNull(names); Assert.assertEquals(3, names.size()); }
public Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role) throws ShepherException { return userBiz.listNames(teamIds, status, role); }
UserService { public Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role) throws ShepherException { return userBiz.listNames(teamIds, status, role); } }
UserService { public Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role) throws ShepherException { return userBiz.listNames(teamIds, status, role); } }
UserService { public Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role) throws ShepherException { return userBiz.listNames(teamIds, status, role); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
UserService { public Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role) throws ShepherException { return userBiz.listNames(teamIds, status, role); } User get(long id); User get(String name); User create(String name); User createIfNotExist(String name); List<User> listByTeams(Set<Long> teams, Status status, Role role); Set<String> listNamesByTeams(Set<Long> teamIds, Status status, Role role); }
@Test public void testAddForPermissionIdTeamIdStatus() throws Exception { long permissionId = 3; long teamId = 5; Status status = Status.AGREE; PermissionTeam permissionTeam = permissionService.add(permissionId, teamId, status); Assert.assertNotNull(permissionTeam); Assert.assertEquals(4, permissionTeam.getId()); }
public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testAddForTeamIdClusterPathStatus() throws Exception { long teamId = 5; Status status = Status.AGREE; String cluster = "local_test"; String path = "/test"; boolean addResult = permissionService.add(teamId, cluster, path, status); Assert.assertEquals(true, addResult); }
public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public PermissionTeam add(long permissionId, long teamId, Status status) throws ShepherException { return permissionTeamBiz.create(permissionId, teamId, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testAddPending() throws Exception { long teamId = 5; String cluster = "local_test"; String path = "/test"; boolean addResult = permissionService.addPending(teamId, cluster, path); Assert.assertEquals(true, addResult); }
public boolean addPending(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.PENDING); }
PermissionService { public boolean addPending(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.PENDING); } }
PermissionService { public boolean addPending(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.PENDING); } }
PermissionService { public boolean addPending(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.PENDING); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public boolean addPending(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.PENDING); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testAddAgree() throws Exception { long teamId = 5; String cluster = "local_test"; String path = "/test"; boolean addResult = permissionService.addAgree(teamId, cluster, path); Assert.assertEquals(true, addResult); }
public boolean addAgree(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.AGREE); }
PermissionService { public boolean addAgree(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.AGREE); } }
PermissionService { public boolean addAgree(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.AGREE); } }
PermissionService { public boolean addAgree(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.AGREE); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public boolean addAgree(long teamId, String cluster, String path) throws ShepherException { return this.add(teamId, cluster, path, Status.AGREE); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testListPermissionTeamsAgree() throws Exception { List<PermissionTeam> permissionTeams = permissionService.listPermissionTeamsAgree(); Assert.assertNotNull(permissionTeams); Assert.assertEquals(1, permissionTeams.size()); }
public List<PermissionTeam> listPermissionTeamsAgree() throws ShepherException { return permissionTeamBiz.list(Status.AGREE); }
PermissionService { public List<PermissionTeam> listPermissionTeamsAgree() throws ShepherException { return permissionTeamBiz.list(Status.AGREE); } }
PermissionService { public List<PermissionTeam> listPermissionTeamsAgree() throws ShepherException { return permissionTeamBiz.list(Status.AGREE); } }
PermissionService { public List<PermissionTeam> listPermissionTeamsAgree() throws ShepherException { return permissionTeamBiz.list(Status.AGREE); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public List<PermissionTeam> listPermissionTeamsAgree() throws ShepherException { return permissionTeamBiz.list(Status.AGREE); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testListPermissionTeamsByTeam() throws Exception { long teamId = 5; List<PermissionTeam> permissionTeams = permissionService.listPermissionTeamsByTeam(teamId, Status.AGREE); Assert.assertNotNull(permissionTeams); Assert.assertEquals(1, permissionTeams.size()); }
public List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status) throws ShepherException { return permissionTeamBiz.listByTeam(teamId, status); }
PermissionService { public List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status) throws ShepherException { return permissionTeamBiz.listByTeam(teamId, status); } }
PermissionService { public List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status) throws ShepherException { return permissionTeamBiz.listByTeam(teamId, status); } }
PermissionService { public List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status) throws ShepherException { return permissionTeamBiz.listByTeam(teamId, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status) throws ShepherException { return permissionTeamBiz.listByTeam(teamId, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testCreate() throws Exception { nodeService.create("local_test", "/test", "data", "creator"); }
public void create(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.create(cluster, path, data); long zkCreationTime = nodeDAO.getCreationTime(cluster, path); snapshotBiz.create(cluster, path, data, creator, Action.ADD, zkCreationTime, ReviewStatus.ACCEPTED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER); logger.info("Create node, cluster={}, path={}, operator={}", cluster, path, creator); }
NodeService { public void create(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.create(cluster, path, data); long zkCreationTime = nodeDAO.getCreationTime(cluster, path); snapshotBiz.create(cluster, path, data, creator, Action.ADD, zkCreationTime, ReviewStatus.ACCEPTED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER); logger.info("Create node, cluster={}, path={}, operator={}", cluster, path, creator); } }
NodeService { public void create(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.create(cluster, path, data); long zkCreationTime = nodeDAO.getCreationTime(cluster, path); snapshotBiz.create(cluster, path, data, creator, Action.ADD, zkCreationTime, ReviewStatus.ACCEPTED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER); logger.info("Create node, cluster={}, path={}, operator={}", cluster, path, creator); } }
NodeService { public void create(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.create(cluster, path, data); long zkCreationTime = nodeDAO.getCreationTime(cluster, path); snapshotBiz.create(cluster, path, data, creator, Action.ADD, zkCreationTime, ReviewStatus.ACCEPTED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER); logger.info("Create node, cluster={}, path={}, operator={}", cluster, path, creator); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
NodeService { public void create(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.create(cluster, path, data); long zkCreationTime = nodeDAO.getCreationTime(cluster, path); snapshotBiz.create(cluster, path, data, creator, Action.ADD, zkCreationTime, ReviewStatus.ACCEPTED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER); logger.info("Create node, cluster={}, path={}, operator={}", cluster, path, creator); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
@Test public void testListPermissionTeamsPending() throws Exception { List<PermissionTeam> permissionTeams = permissionService.listPermissionTeamsPending(); Assert.assertNotNull(permissionTeams); Assert.assertEquals(1, permissionTeams.size()); }
public List<PermissionTeam> listPermissionTeamsPending() throws ShepherException { return permissionTeamBiz.list(Status.PENDING); }
PermissionService { public List<PermissionTeam> listPermissionTeamsPending() throws ShepherException { return permissionTeamBiz.list(Status.PENDING); } }
PermissionService { public List<PermissionTeam> listPermissionTeamsPending() throws ShepherException { return permissionTeamBiz.list(Status.PENDING); } }
PermissionService { public List<PermissionTeam> listPermissionTeamsPending() throws ShepherException { return permissionTeamBiz.list(Status.PENDING); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public List<PermissionTeam> listPermissionTeamsPending() throws ShepherException { return permissionTeamBiz.list(Status.PENDING); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testUpdateStatus() throws Exception { int id = 3; Status status = Status.AGREE; int updateResult = permissionService.updateStatus(id, status); Assert.assertEquals(RESULT_OK, updateResult); }
public int updateStatus(long id, Status status) throws ShepherException { return permissionTeamBiz.update(id, status); }
PermissionService { public int updateStatus(long id, Status status) throws ShepherException { return permissionTeamBiz.update(id, status); } }
PermissionService { public int updateStatus(long id, Status status) throws ShepherException { return permissionTeamBiz.update(id, status); } }
PermissionService { public int updateStatus(long id, Status status) throws ShepherException { return permissionTeamBiz.update(id, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public int updateStatus(long id, Status status) throws ShepherException { return permissionTeamBiz.update(id, status); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testIsPathMember() throws Exception { long userId = 3; String cluster = "local_test"; String path = "/test/sub1"; boolean isMember = permissionService.isPathMember(userId, cluster, path); Assert.assertEquals(true, isMember); }
public boolean isPathMember(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MEMBER, userId); }
PermissionService { public boolean isPathMember(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MEMBER, userId); } }
PermissionService { public boolean isPathMember(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MEMBER, userId); } }
PermissionService { public boolean isPathMember(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MEMBER, userId); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public boolean isPathMember(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MEMBER, userId); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testIsPathMasterForUserIdClusterPath() throws Exception { long userId = 3; String cluster = "local_test"; String path = "/test/sub1"; boolean isMaster = permissionService.isPathMaster(userId, cluster, path); Assert.assertEquals(true, isMaster); }
public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testIsPathMasterForUserNameClusterPath() throws Exception { String userName = "testuser"; String cluster = "local_test"; String path = "/test/sub1"; boolean isMaster = permissionService.isPathMaster(userName, cluster, path); Assert.assertEquals(true, isMaster); }
public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
PermissionService { public boolean isPathMaster(long userId, String cluster, String path) throws ShepherException { if (ClusterUtil.isPublicCluster(cluster)) { return true; } return teamBiz.isAboveRole(cluster, path, Role.MASTER, userId); } PermissionTeam add(long permissionId, long teamId, Status status); @Transactional boolean add(long teamId, String cluster, String path, Status status); boolean addPending(long teamId, String cluster, String path); boolean addAgree(long teamId, String cluster, String path); List<PermissionTeam> listPermissionTeamsAgree(); List<PermissionTeam> listPermissionTeamsByTeam(long teamId, Status status); List<PermissionTeam> listPermissionTeamsPending(); int updateStatus(long id, Status status); boolean isPathMember(long userId, String cluster, String path); boolean isPathMaster(long userId, String cluster, String path); boolean isPathMaster(String userName, String cluster, String path); }
@Test public void testUpdate() throws Exception { nodeService.update("local_test", "/test", "", ""); }
public void update(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.update(cluster, path, data); Stat stat = nodeDAO.getStat(cluster, path, true); snapshotBiz.create(cluster, path, data, creator, Action.UPDATE, stat.getCtime(), ReviewStatus.ACCEPTED, stat.getVersion(), ReviewUtil.DEFAULT_REVIEWER); logger.info("Update node, cluster={}, path={}, operator={}", cluster, path, creator); }
NodeService { public void update(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.update(cluster, path, data); Stat stat = nodeDAO.getStat(cluster, path, true); snapshotBiz.create(cluster, path, data, creator, Action.UPDATE, stat.getCtime(), ReviewStatus.ACCEPTED, stat.getVersion(), ReviewUtil.DEFAULT_REVIEWER); logger.info("Update node, cluster={}, path={}, operator={}", cluster, path, creator); } }
NodeService { public void update(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.update(cluster, path, data); Stat stat = nodeDAO.getStat(cluster, path, true); snapshotBiz.create(cluster, path, data, creator, Action.UPDATE, stat.getCtime(), ReviewStatus.ACCEPTED, stat.getVersion(), ReviewUtil.DEFAULT_REVIEWER); logger.info("Update node, cluster={}, path={}, operator={}", cluster, path, creator); } }
NodeService { public void update(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.update(cluster, path, data); Stat stat = nodeDAO.getStat(cluster, path, true); snapshotBiz.create(cluster, path, data, creator, Action.UPDATE, stat.getCtime(), ReviewStatus.ACCEPTED, stat.getVersion(), ReviewUtil.DEFAULT_REVIEWER); logger.info("Update node, cluster={}, path={}, operator={}", cluster, path, creator); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
NodeService { public void update(String cluster, String path, String data, String creator) throws ShepherException { nodeBiz.update(cluster, path, data); Stat stat = nodeDAO.getStat(cluster, path, true); snapshotBiz.create(cluster, path, data, creator, Action.UPDATE, stat.getCtime(), ReviewStatus.ACCEPTED, stat.getVersion(), ReviewUtil.DEFAULT_REVIEWER); logger.info("Update node, cluster={}, path={}, operator={}", cluster, path, creator); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
@Test public void testDelete() throws Exception { nodeService.delete("local_test", "/test", ""); }
public void delete(String cluster, String path, String creator) throws ShepherException { nodeBiz.delete(cluster, path); long snapshotId = snapshotBiz.create(cluster, path, ReviewUtil.EMPTY_CONTENT, creator, Action.DELETE, ReviewUtil.DEFAULT_MTIME, ReviewStatus.DELETED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPath(cluster, path, Role.MASTER); mailSenderFactory.getMailSender().noticeDelete(masters, creator, path, cluster, serverUrl + "/snapshots/" + snapshotId); logger.info("Delete node, cluster={}, path={}, operator={}", cluster, path, creator); }
NodeService { public void delete(String cluster, String path, String creator) throws ShepherException { nodeBiz.delete(cluster, path); long snapshotId = snapshotBiz.create(cluster, path, ReviewUtil.EMPTY_CONTENT, creator, Action.DELETE, ReviewUtil.DEFAULT_MTIME, ReviewStatus.DELETED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPath(cluster, path, Role.MASTER); mailSenderFactory.getMailSender().noticeDelete(masters, creator, path, cluster, serverUrl + "/snapshots/" + snapshotId); logger.info("Delete node, cluster={}, path={}, operator={}", cluster, path, creator); } }
NodeService { public void delete(String cluster, String path, String creator) throws ShepherException { nodeBiz.delete(cluster, path); long snapshotId = snapshotBiz.create(cluster, path, ReviewUtil.EMPTY_CONTENT, creator, Action.DELETE, ReviewUtil.DEFAULT_MTIME, ReviewStatus.DELETED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPath(cluster, path, Role.MASTER); mailSenderFactory.getMailSender().noticeDelete(masters, creator, path, cluster, serverUrl + "/snapshots/" + snapshotId); logger.info("Delete node, cluster={}, path={}, operator={}", cluster, path, creator); } }
NodeService { public void delete(String cluster, String path, String creator) throws ShepherException { nodeBiz.delete(cluster, path); long snapshotId = snapshotBiz.create(cluster, path, ReviewUtil.EMPTY_CONTENT, creator, Action.DELETE, ReviewUtil.DEFAULT_MTIME, ReviewStatus.DELETED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPath(cluster, path, Role.MASTER); mailSenderFactory.getMailSender().noticeDelete(masters, creator, path, cluster, serverUrl + "/snapshots/" + snapshotId); logger.info("Delete node, cluster={}, path={}, operator={}", cluster, path, creator); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
NodeService { public void delete(String cluster, String path, String creator) throws ShepherException { nodeBiz.delete(cluster, path); long snapshotId = snapshotBiz.create(cluster, path, ReviewUtil.EMPTY_CONTENT, creator, Action.DELETE, ReviewUtil.DEFAULT_MTIME, ReviewStatus.DELETED, ReviewUtil.NEW_CREATE_VERSION, ReviewUtil.DEFAULT_REVIEWER).getId(); Set<String> masters = teamBiz.listUserNamesByPath(cluster, path, Role.MASTER); mailSenderFactory.getMailSender().noticeDelete(masters, creator, path, cluster, serverUrl + "/snapshots/" + snapshotId); logger.info("Delete node, cluster={}, path={}, operator={}", cluster, path, creator); } List<String> getChildren(String cluster, String path); String getData(String cluster, String path); Stat getStat(String cluster, String path); Stat getStat(String cluster, String path, boolean returnNullIfPathNotExists); void create(String cluster, String path, String data, String creator); void create(String cluster, String path, String data, String creator, boolean createParents); void createEphemeral(String cluster, String path, String data, String creator); void updateWithPermission(String cluster, String path, String data, String creator); void update(String cluster, String path, String data, String creator); void delete(String cluster, String path, String creator); }
@Test public void testCreate() throws Exception { clusterAdminService.create("name", "config"); List<Cluster> clusters = clusterAdminService.all(); Assert.assertNotNull(clusters); Assert.assertEquals(2, clusters.size()); thrown.expect(ShepherException.class); clusterAdminService.create(null, "config"); clusterAdminService.create("local_test", "config"); }
public void create(String name, String config) throws ShepherException { clusterAdminBiz.create(name, config); logger.info("Create cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); }
ClusterAdminService { public void create(String name, String config) throws ShepherException { clusterAdminBiz.create(name, config); logger.info("Create cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } }
ClusterAdminService { public void create(String name, String config) throws ShepherException { clusterAdminBiz.create(name, config); logger.info("Create cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } }
ClusterAdminService { public void create(String name, String config) throws ShepherException { clusterAdminBiz.create(name, config); logger.info("Create cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
ClusterAdminService { public void create(String name, String config) throws ShepherException { clusterAdminBiz.create(name, config); logger.info("Create cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
@Test public void testUpdate() throws Exception { clusterAdminService.update("local_test", "config"); List<Cluster> clusters = clusterAdminService.all(); Assert.assertNotNull(clusters); Assert.assertEquals(1, clusters.size()); Assert.assertEquals("config", clusters.get(0).getConfig()); thrown.expect(ShepherException.class); clusterAdminService.update(null, "config"); }
public void update(String name, String config) throws ShepherException { clusterAdminBiz.update(name, config); logger.info("Update cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); }
ClusterAdminService { public void update(String name, String config) throws ShepherException { clusterAdminBiz.update(name, config); logger.info("Update cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } }
ClusterAdminService { public void update(String name, String config) throws ShepherException { clusterAdminBiz.update(name, config); logger.info("Update cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } }
ClusterAdminService { public void update(String name, String config) throws ShepherException { clusterAdminBiz.update(name, config); logger.info("Update cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
ClusterAdminService { public void update(String name, String config) throws ShepherException { clusterAdminBiz.update(name, config); logger.info("Update cluster, config={}, name={}, operator={}", config, name, userHolder.getUser().getName()); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
@Test public void testDelete() throws Exception { clusterAdminService.delete("local_test"); List<Cluster> clusters = clusterAdminService.all(); Assert.assertNotNull(clusters); Assert.assertEquals(0, clusters.size()); thrown.expect(ShepherException.class); clusterAdminService.delete(null); }
public void delete(String name) throws ShepherException { clusterAdminBiz.delete(name); logger.info("Delete cluster, name={}, operator={}", name, userHolder.getUser().getName()); }
ClusterAdminService { public void delete(String name) throws ShepherException { clusterAdminBiz.delete(name); logger.info("Delete cluster, name={}, operator={}", name, userHolder.getUser().getName()); } }
ClusterAdminService { public void delete(String name) throws ShepherException { clusterAdminBiz.delete(name); logger.info("Delete cluster, name={}, operator={}", name, userHolder.getUser().getName()); } }
ClusterAdminService { public void delete(String name) throws ShepherException { clusterAdminBiz.delete(name); logger.info("Delete cluster, name={}, operator={}", name, userHolder.getUser().getName()); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
ClusterAdminService { public void delete(String name) throws ShepherException { clusterAdminBiz.delete(name); logger.info("Delete cluster, name={}, operator={}", name, userHolder.getUser().getName()); } void create(String name, String config); void update(String name, String config); void delete(String name); List<Cluster> all(); }
@Test public void testOf() { for (final Object[] params : new Object[][] { { new FsAccessOption[0], NONE }, { new FsAccessOption[] { CACHE, CREATE_PARENTS, STORE, COMPRESS, GROW, ENCRYPT }, ACCESS_PREFERENCES_MASK }, }) { final FsAccessOption[] array = (FsAccessOption[]) params[0]; final BitField<?> bits = (BitField<?>) params[1]; assertEquals(FsAccessOptions.of(array), bits); } }
public static BitField<FsAccessOption> of(FsAccessOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); }
FsAccessOptions { public static BitField<FsAccessOption> of(FsAccessOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } }
FsAccessOptions { public static BitField<FsAccessOption> of(FsAccessOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } private FsAccessOptions(); }
FsAccessOptions { public static BitField<FsAccessOption> of(FsAccessOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } private FsAccessOptions(); static BitField<FsAccessOption> of(FsAccessOption... options); }
FsAccessOptions { public static BitField<FsAccessOption> of(FsAccessOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } private FsAccessOptions(); static BitField<FsAccessOption> of(FsAccessOption... options); static final BitField<FsAccessOption> NONE; static final BitField<FsAccessOption> ACCESS_PREFERENCES_MASK; }
@Test public void testToHierarchicalUri() { for (final String[] params : new String[][] { { "foo:bar:baz:/x/bö%20m?plö%20k!/bä%20g?zö%20k!/", "baz:/x/bö%20m/bä%20g?zö%20k" }, { "foo:bar:baz:/x/bööm?plönk!/bäng?zönk!/", "baz:/x/bööm/bäng?zönk" }, { "foo:bar:baz:/boom?plonk!/bang?zonk!/", "baz:/boom/bang?zonk" }, { "foo:bar:baz:/boom!/bang!/", "baz:/boom/bang" }, { "foo:bar:/baz?boom!/", "bar:/baz?boom" }, { "foo:bar:/baz!/", "bar:/baz" }, { "foo:/bar/", "foo:/bar/" }, }) { final FsMountPoint mp = FsMountPoint.create(URI.create(params[0])); final URI hmp = mp.toHierarchicalUri(); final FsNodePath p = FsNodePath.create(URI.create(params[0])); final URI hp = p.toHierarchicalUri(); assertThat(hmp, equalTo(URI.create(params[1]))); assertThat(hmp, equalTo(hp)); } }
public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; return null != hierarchical ? hierarchical : (this.hierarchical = uri.isOpaque() ? path.toHierarchicalUri() : uri); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; return null != hierarchical ? hierarchical : (this.hierarchical = uri.isOpaque() ? path.toHierarchicalUri() : uri); } }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; return null != hierarchical ? hierarchical : (this.hierarchical = uri.isOpaque() ? path.toHierarchicalUri() : uri); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; return null != hierarchical ? hierarchical : (this.hierarchical = uri.isOpaque() ? path.toHierarchicalUri() : uri); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); static FsMountPoint create(URI uri); static FsMountPoint create(URI uri, FsUriModifier modifier); static FsMountPoint create(FsScheme scheme, FsNodePath path); URI getUri(); URI toHierarchicalUri(); FsScheme getScheme(); @Nullable FsNodePath getPath(); @Nullable FsMountPoint getParent(); FsNodePath resolve(FsNodeName name); @Override int compareTo(FsMountPoint that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; return null != hierarchical ? hierarchical : (this.hierarchical = uri.isOpaque() ? path.toHierarchicalUri() : uri); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); static FsMountPoint create(URI uri); static FsMountPoint create(URI uri, FsUriModifier modifier); static FsMountPoint create(FsScheme scheme, FsNodePath path); URI getUri(); URI toHierarchicalUri(); FsScheme getScheme(); @Nullable FsNodePath getPath(); @Nullable FsMountPoint getParent(); FsNodePath resolve(FsNodeName name); @Override int compareTo(FsMountPoint that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); static final String SEPARATOR; }
@Test public void testPriority() { assertTrue(new FileBufferPoolFactory().getPriority() < 0); }
@Override public int getPriority() { return -100; }
FileBufferPoolFactory extends IoBufferPoolFactory { @Override public int getPriority() { return -100; } }
FileBufferPoolFactory extends IoBufferPoolFactory { @Override public int getPriority() { return -100; } }
FileBufferPoolFactory extends IoBufferPoolFactory { @Override public int getPriority() { return -100; } @Override IoBufferPool get(); @Override int getPriority(); }
FileBufferPoolFactory extends IoBufferPoolFactory { @Override public int getPriority() { return -100; } @Override IoBufferPool get(); @Override int getPriority(); }
@Test public void testCheck() { try { UShort.check(UShort.MIN_VALUE - 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } UShort.check(UShort.MIN_VALUE); UShort.check(UShort.MAX_VALUE); try { UShort.check(UShort.MAX_VALUE + 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } }
public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); }
UShort { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } }
UShort { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UShort(); }
UShort { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UShort(); static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final int i); }
UShort { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UShort(); static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final int i); static final int MIN_VALUE; static final int MAX_VALUE; static final int SIZE; }
@Test public void testCheck() { try { ULong.check(ULong.MIN_VALUE - 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } ULong.check(ULong.MIN_VALUE); ULong.check(ULong.MAX_VALUE); }
public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); }
ULong { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } }
ULong { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private ULong(); }
ULong { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private ULong(); static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final long l); }
ULong { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private ULong(); static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final long l); static final long MIN_VALUE; static final long MAX_VALUE; static final int SIZE; }
@Test public void testRegister() { try { ExtraField.register(null); fail(); } catch (NullPointerException expected) { } try { ExtraField.register(TooSmallHeaderIDExtraField.class); fail(); } catch (IllegalArgumentException expected) { } try { ExtraField.register(TooLargeHeaderIDExtraField.class); fail(); } catch (IllegalArgumentException expected) { } ExtraField.register(NullExtraField.class); }
static void register(final Class<? extends ExtraField> c) { final ExtraField ef; try { ef = c.getDeclaredConstructor().newInstance(); } catch (NullPointerException ex) { throw ex; } catch (Exception ex) { throw new IllegalArgumentException(ex); } final int headerId = ef.getHeaderId(); assert UShort.check(headerId); registry.put(headerId, c); }
ExtraField { static void register(final Class<? extends ExtraField> c) { final ExtraField ef; try { ef = c.getDeclaredConstructor().newInstance(); } catch (NullPointerException ex) { throw ex; } catch (Exception ex) { throw new IllegalArgumentException(ex); } final int headerId = ef.getHeaderId(); assert UShort.check(headerId); registry.put(headerId, c); } }
ExtraField { static void register(final Class<? extends ExtraField> c) { final ExtraField ef; try { ef = c.getDeclaredConstructor().newInstance(); } catch (NullPointerException ex) { throw ex; } catch (Exception ex) { throw new IllegalArgumentException(ex); } final int headerId = ef.getHeaderId(); assert UShort.check(headerId); registry.put(headerId, c); } }
ExtraField { static void register(final Class<? extends ExtraField> c) { final ExtraField ef; try { ef = c.getDeclaredConstructor().newInstance(); } catch (NullPointerException ex) { throw ex; } catch (Exception ex) { throw new IllegalArgumentException(ex); } final int headerId = ef.getHeaderId(); assert UShort.check(headerId); registry.put(headerId, c); } }
ExtraField { static void register(final Class<? extends ExtraField> c) { final ExtraField ef; try { ef = c.getDeclaredConstructor().newInstance(); } catch (NullPointerException ex) { throw ex; } catch (Exception ex) { throw new IllegalArgumentException(ex); } final int headerId = ef.getHeaderId(); assert UShort.check(headerId); registry.put(headerId, c); } }
@Test public void testCreate() { ExtraField ef; ExtraField.register(NullExtraField.class); ef = ExtraField.create(0x0000); assertTrue(ef instanceof NullExtraField); assertEquals(0x0000, ef.getHeaderId()); ef = ExtraField.create(0x0001); assertTrue(ef instanceof DefaultExtraField); assertEquals(0x0001, ef.getHeaderId()); ef = ExtraField.create(0x0002); assertTrue(ef instanceof DefaultExtraField); assertEquals(0x0002, ef.getHeaderId()); ef = ExtraField.create(UShort.MAX_VALUE); assertTrue(ef instanceof DefaultExtraField); assertEquals(UShort.MAX_VALUE, ef.getHeaderId()); try { ef = ExtraField.create(UShort.MIN_VALUE - 1); fail(); } catch (IllegalArgumentException expected) { } try { ef = ExtraField.create(UShort.MAX_VALUE + 1); fail(); } catch (IllegalArgumentException expected) { } }
static ExtraField create(final int headerId) { assert UShort.check(headerId); final Class<? extends ExtraField> c = registry.get(headerId); final ExtraField ef; try { ef = null != c ? c.getDeclaredConstructor().newInstance() : new DefaultExtraField(headerId); } catch (final Exception cannotHappen) { throw new AssertionError(cannotHappen); } assert headerId == ef.getHeaderId(); return ef; }
ExtraField { static ExtraField create(final int headerId) { assert UShort.check(headerId); final Class<? extends ExtraField> c = registry.get(headerId); final ExtraField ef; try { ef = null != c ? c.getDeclaredConstructor().newInstance() : new DefaultExtraField(headerId); } catch (final Exception cannotHappen) { throw new AssertionError(cannotHappen); } assert headerId == ef.getHeaderId(); return ef; } }
ExtraField { static ExtraField create(final int headerId) { assert UShort.check(headerId); final Class<? extends ExtraField> c = registry.get(headerId); final ExtraField ef; try { ef = null != c ? c.getDeclaredConstructor().newInstance() : new DefaultExtraField(headerId); } catch (final Exception cannotHappen) { throw new AssertionError(cannotHappen); } assert headerId == ef.getHeaderId(); return ef; } }
ExtraField { static ExtraField create(final int headerId) { assert UShort.check(headerId); final Class<? extends ExtraField> c = registry.get(headerId); final ExtraField ef; try { ef = null != c ? c.getDeclaredConstructor().newInstance() : new DefaultExtraField(headerId); } catch (final Exception cannotHappen) { throw new AssertionError(cannotHappen); } assert headerId == ef.getHeaderId(); return ef; } }
ExtraField { static ExtraField create(final int headerId) { assert UShort.check(headerId); final Class<? extends ExtraField> c = registry.get(headerId); final ExtraField ef; try { ef = null != c ? c.getDeclaredConstructor().newInstance() : new DefaultExtraField(headerId); } catch (final Exception cannotHappen) { throw new AssertionError(cannotHappen); } assert headerId == ef.getHeaderId(); return ef; } }
@Test public void testCheck() { try { UByte.check(UByte.MIN_VALUE - 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } UByte.check(UByte.MIN_VALUE); UByte.check(UByte.MAX_VALUE); try { UByte.check(UByte.MAX_VALUE + 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } }
public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); }
UByte { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } }
UByte { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UByte(); }
UByte { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UByte(); static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final int i); }
UByte { public static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= i && i <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(i) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UByte(); static boolean check( final int i, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final int i); static final short MIN_VALUE; static final short MAX_VALUE; static final int SIZE; }
@Test public void testCheck() { try { UInt.check(UInt.MIN_VALUE - 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } UInt.check(UInt.MIN_VALUE); UInt.check(UInt.MAX_VALUE); try { UInt.check(UInt.MAX_VALUE + 1); fail("Expected IllegalArgumentException!"); } catch (IllegalArgumentException expected) { } }
public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l && l <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); }
UInt { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l && l <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } }
UInt { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l && l <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UInt(); }
UInt { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l && l <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UInt(); static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final long l); }
UInt { public static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error) { if (MIN_VALUE <= l && l <= MAX_VALUE) return true; final StringBuilder message = new StringBuilder(); if (null != subject) message.append(subject).append(": "); if (null != error) message.append(error).append(": "); throw new IllegalArgumentException(message .append(l) .append(" is not within ") .append(MIN_VALUE) .append(" and ") .append(MAX_VALUE) .append(" inclusive.") .toString()); } private UInt(); static boolean check( final long l, final @CheckForNull String subject, final @CheckForNull String error); static boolean check(final long l); static final long MIN_VALUE; static final long MAX_VALUE; static final int SIZE; }
@Test public void testClone() { ZipEntry clone = entry.clone(); assertNotSame(clone, entry); }
@Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public ZipEntry clone() { final ZipEntry entry; try { entry = (ZipEntry) super.clone(); } catch (CloneNotSupportedException ex) { throw new AssertionError(ex); } final ExtraFields fields = this.fields; entry.fields = fields == null ? null : fields.clone(); return entry; }
ZipEntry implements Cloneable { @Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public ZipEntry clone() { final ZipEntry entry; try { entry = (ZipEntry) super.clone(); } catch (CloneNotSupportedException ex) { throw new AssertionError(ex); } final ExtraFields fields = this.fields; entry.fields = fields == null ? null : fields.clone(); return entry; } }
ZipEntry implements Cloneable { @Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public ZipEntry clone() { final ZipEntry entry; try { entry = (ZipEntry) super.clone(); } catch (CloneNotSupportedException ex) { throw new AssertionError(ex); } final ExtraFields fields = this.fields; entry.fields = fields == null ? null : fields.clone(); return entry; } ZipEntry(final String name); @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") protected ZipEntry(final String name, final ZipEntry template); }
ZipEntry implements Cloneable { @Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public ZipEntry clone() { final ZipEntry entry; try { entry = (ZipEntry) super.clone(); } catch (CloneNotSupportedException ex) { throw new AssertionError(ex); } final ExtraFields fields = this.fields; entry.fields = fields == null ? null : fields.clone(); return entry; } ZipEntry(final String name); @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") protected ZipEntry(final String name, final ZipEntry template); @Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") ZipEntry clone(); final String getName(); final boolean isDirectory(); final int getPlatform(); final void setPlatform(final int platform); final boolean isEncrypted(); final void setEncrypted(boolean encrypted); final void clearEncryption(); final int getMethod(); final void setMethod(final int method); final long getTime(); final void setTime(final long jtime); final long getCrc(); final void setCrc(final long crc); final long getCompressedSize(); final void setCompressedSize(final long csize); final long getSize(); final void setSize(final long size); final long getExternalAttributes(); final void setExternalAttributes(final long eattr); final byte[] getExtra(); final void setExtra(final @CheckForNull byte[] buf); final @CheckForNull String getComment(); final void setComment(final @CheckForNull String comment); @Override String toString(); }
ZipEntry implements Cloneable { @Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") public ZipEntry clone() { final ZipEntry entry; try { entry = (ZipEntry) super.clone(); } catch (CloneNotSupportedException ex) { throw new AssertionError(ex); } final ExtraFields fields = this.fields; entry.fields = fields == null ? null : fields.clone(); return entry; } ZipEntry(final String name); @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") protected ZipEntry(final String name, final ZipEntry template); @Override @SuppressWarnings("AccessingNonPublicFieldOfAnotherObject") ZipEntry clone(); final String getName(); final boolean isDirectory(); final int getPlatform(); final void setPlatform(final int platform); final boolean isEncrypted(); final void setEncrypted(boolean encrypted); final void clearEncryption(); final int getMethod(); final void setMethod(final int method); final long getTime(); final void setTime(final long jtime); final long getCrc(); final void setCrc(final long crc); final long getCompressedSize(); final void setCompressedSize(final long csize); final long getSize(); final void setSize(final long size); final long getExternalAttributes(); final void setExternalAttributes(final long eattr); final byte[] getExtra(); final void setExtra(final @CheckForNull byte[] buf); final @CheckForNull String getComment(); final void setComment(final @CheckForNull String comment); @Override String toString(); static final byte UNKNOWN; static final short PLATFORM_FAT; static final short PLATFORM_UNIX; static final int STORED; static final int DEFLATED; static final int BZIP2; static final long MIN_DOS_TIME; static final long MAX_DOS_TIME; }
@Test public void testGetDataSize() { assertEquals(0, field.getDataSize()); }
@Override int getDataSize() { final byte[] data = this.data; return null != data ? data.length : 0; }
DefaultExtraField extends ExtraField { @Override int getDataSize() { final byte[] data = this.data; return null != data ? data.length : 0; } }
DefaultExtraField extends ExtraField { @Override int getDataSize() { final byte[] data = this.data; return null != data ? data.length : 0; } DefaultExtraField(final int headerId); }
DefaultExtraField extends ExtraField { @Override int getDataSize() { final byte[] data = this.data; return null != data ? data.length : 0; } DefaultExtraField(final int headerId); }
DefaultExtraField extends ExtraField { @Override int getDataSize() { final byte[] data = this.data; return null != data ? data.length : 0; } DefaultExtraField(final int headerId); }
@Test @SuppressWarnings("ResultOfObjectAllocationIgnored") public void testConstructorWithInvalidUri() throws URISyntaxException { try { FsScheme.create(null); fail(); } catch (NullPointerException expected) { } try { new FsScheme(null); fail(); } catch (NullPointerException expected) { } for (final String param : new String[] { "", "+", "-", ".", }) { try { FsScheme.create(param); fail(param); } catch (IllegalArgumentException expected) { } try { new FsScheme(param); fail(param); } catch (URISyntaxException expected) { } } }
public static FsScheme create(String scheme) { try { return new FsScheme(scheme); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } }
FsScheme implements Serializable, Comparable<FsScheme> { public static FsScheme create(String scheme) { try { return new FsScheme(scheme); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } } }
FsScheme implements Serializable, Comparable<FsScheme> { public static FsScheme create(String scheme) { try { return new FsScheme(scheme); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } } @ConstructorProperties("scheme") FsScheme(final String scheme); }
FsScheme implements Serializable, Comparable<FsScheme> { public static FsScheme create(String scheme) { try { return new FsScheme(scheme); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } } @ConstructorProperties("scheme") FsScheme(final String scheme); static FsScheme create(String scheme); @Deprecated String getScheme(); @Override boolean equals(Object that); @Override int compareTo(FsScheme that); @Override int hashCode(); @Override String toString(); }
FsScheme implements Serializable, Comparable<FsScheme> { public static FsScheme create(String scheme) { try { return new FsScheme(scheme); } catch (URISyntaxException ex) { throw new IllegalArgumentException(ex); } } @ConstructorProperties("scheme") FsScheme(final String scheme); static FsScheme create(String scheme); @Deprecated String getScheme(); @Override boolean equals(Object that); @Override int compareTo(FsScheme that); @Override int hashCode(); @Override String toString(); }
@Test public void testSetup() { instance.setup(); }
@SuppressWarnings("NoopMethodInAbstractClass") protected void setup() { }
TApplication { @SuppressWarnings("NoopMethodInAbstractClass") protected void setup() { } }
TApplication { @SuppressWarnings("NoopMethodInAbstractClass") protected void setup() { } }
TApplication { @SuppressWarnings("NoopMethodInAbstractClass") protected void setup() { } }
TApplication { @SuppressWarnings("NoopMethodInAbstractClass") protected void setup() { } }
@Test public void testWork() { try { instance.work(null); } catch (NullPointerException expected) { } assertEquals(0, instance.work(new String[0])); }
protected abstract int work(String[] args) throws E;
TApplication { protected abstract int work(String[] args) throws E; }
TApplication { protected abstract int work(String[] args) throws E; }
TApplication { protected abstract int work(String[] args) throws E; }
TApplication { protected abstract int work(String[] args) throws E; }
@Test public void testOf() { for (final Object[] params : new Object[][] { { new FsSyncOption[0], NONE }, { new FsSyncOption[] { ABORT_CHANGES }, RESET }, { new FsSyncOption[] { WAIT_CLOSE_IO }, SYNC }, { new FsSyncOption[] { FORCE_CLOSE_IO, CLEAR_CACHE }, UMOUNT }, }) { final FsSyncOption[] array = (FsSyncOption[]) params[0]; final BitField<?> bits = (BitField<?>) params[1]; assertEquals(bits, FsSyncOptions.of(array)); } }
public static BitField<FsSyncOption> of(FsSyncOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); }
FsSyncOptions { public static BitField<FsSyncOption> of(FsSyncOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } }
FsSyncOptions { public static BitField<FsSyncOption> of(FsSyncOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } private FsSyncOptions(); }
FsSyncOptions { public static BitField<FsSyncOption> of(FsSyncOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } private FsSyncOptions(); static BitField<FsSyncOption> of(FsSyncOption... options); }
FsSyncOptions { public static BitField<FsSyncOption> of(FsSyncOption... options) { return 0 == options.length ? NONE : BitField.of(options[0], options); } private FsSyncOptions(); static BitField<FsSyncOption> of(FsSyncOption... options); static final BitField<FsSyncOption> NONE; static final BitField<FsSyncOption> UMOUNT; static final BitField<FsSyncOption> SYNC; static final BitField<FsSyncOption> RESET; }
@Test @SuppressWarnings("ResultOfObjectAllocationIgnored") public void testConstructorWithInvalidUri() throws URISyntaxException { try { FsNodePath.create((URI) null); fail(); } catch (NullPointerException expected) { } try { new FsNodePath((URI) null); fail(); } catch (NullPointerException expected) { } try { FsNodePath.create((URI) null, NULL); fail(); } catch (NullPointerException expected) { } try { new FsNodePath((URI) null, NULL); fail(); } catch (NullPointerException expected) { } try { FsNodePath.create((URI) null, CANONICALIZE); fail(); } catch (NullPointerException expected) { } try { new FsNodePath((URI) null, CANONICALIZE); fail(); } catch (NullPointerException expected) { } try { new FsNodePath((FsMountPoint) null, null); fail(); } catch (NullPointerException expected) { } for (final String param : new String[] { "/../foo#boo", "/../foo#", "/../foo", "/./foo", " "/foo", "/foo/bar", "/foo/bar/", "/", "foo#fragmentDefined", "foo/", "foo "foo/.", "foo/./", "foo/..", "foo/../", "foo:/bar/.", "foo:/bar/..", "foo:bar", "foo:bar:", "foo:bar:/", "foo:bar:/baz", "foo:bar:/baz!", "foo:bar:/baz/", "foo:bar:/baz! "foo:bar:/baz!/.", "foo:bar:/baz!/./", "foo:bar:/baz!/..", "foo:bar:/baz!/../", "foo:bar:/baz!/bang/.", "foo:bar:/baz!/bang/./", "foo:bar:/baz!/bang/..", "foo:bar:/baz!/bang/../", "foo:bar:baz:/bang", "foo:bar:baz:/bang!", "foo:bar:baz:/bang/", "foo:bar:baz:/bang!/", "foo:bar:baz:/bang!/boom", "foo:bar:/baz/.!/", "foo:bar:/baz/./!/", "foo:bar:/baz/..!/", "foo:bar:/baz/../!/", "foo:bar:/baz/../!/bang/", "foo:bar:/baz/..!/bang/", "foo:bar:/baz/./!/bang/", "foo:bar:/baz/.!/bang/", "foo:bar:/../baz/!/bang/", "foo:bar:/./baz/!/bang/", "foo:bar: "foo:bar: "foo:bar:/!/bang/", "foo:bar:/baz/../!/bang", "foo:bar:/baz/..!/bang", "foo:bar:/baz/./!/bang", "foo:bar:/baz/.!/bang", "foo:bar:/../baz/!/bang", "foo:bar:/./baz/!/bang", "foo:bar: "foo:bar: "foo:bar:/!/bang", "foo:bar:/baz/!/", "foo:bar:/baz/?bang!/?plonk", "foo:bar:/baz "foo:bar:/baz/./!/", "foo:bar:/baz/..!/", "foo:bar:/baz/../!/", " }) { final URI uri = URI.create(param); try { FsNodePath.create(uri); fail(param); } catch (IllegalArgumentException expected) { } try { new FsNodePath(uri); fail(param); } catch (URISyntaxException expected) { } } }
public static FsNodePath create(URI uri) { return create(uri, NULL); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); static FsNodePath create(URI uri); static FsNodePath create(URI uri, FsUriModifier modifier); URI getUri(); URI toHierarchicalUri(); @Nullable FsMountPoint getMountPoint(); FsNodeName getNodeName(); FsNodePath resolve(final FsNodeName nodeName); @Override int compareTo(FsNodePath that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); static FsNodePath create(URI uri); static FsNodePath create(URI uri, FsUriModifier modifier); URI getUri(); URI toHierarchicalUri(); @Nullable FsMountPoint getMountPoint(); FsNodeName getNodeName(); FsNodePath resolve(final FsNodeName nodeName); @Override int compareTo(FsNodePath that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
@Test @SuppressWarnings("ResultOfObjectAllocationIgnored") public void testConstructorWithValidUri() { for (final String[] params : new String[][] { { "foo:bar:baz:/bä%20ng!/bö%20öm!/plö%20nk", "foo:bar:baz:/bä%20ng!/bö%20öm!/", "plö%20nk" }, { "foo:bar:baz:/bäng!/bööm!/plönk", "foo:bar:baz:/bäng!/bööm!/", "plönk" }, { "foo:bar:baz:/bang!/boom!/plonk", "foo:bar:baz:/bang!/boom!/", "plonk" }, { "foo:bar:baz:/bang!/boom!/", "foo:bar:baz:/bang!/boom!/", "" }, { "foo:bar:/baz!/bang/../", "foo:bar:/baz!/", "" }, { "foo:bar:/baz!/bang/..", "foo:bar:/baz!/", "" }, { "foo:bar:/baz!/bang", "foo:bar:/baz!/", "bang" }, { "foo:bar:/baz!/./", "foo:bar:/baz!/", "" }, { "foo:bar:/baz!/.", "foo:bar:/baz!/", "" }, { "foo:bar:/baz!/", "foo:bar:/baz!/", "" }, { "foo:bar:/baz?bang!/?plonk", "foo:bar:/baz?bang!/", "?plonk" }, { "foo:bar:/baz!/bang/..", "foo:bar:/baz!/", "" }, { "foo:bar:/baz!/bang/../", "foo:bar:/baz!/", "" }, { "", null, "", }, { "foo", null, "foo" }, { "foo/..", null, "" }, { "foo/../", null, "" }, { "foo/bar", null, "foo/bar" }, { "foo:/", "foo:/", "" }, { "foo:/bar", "foo:/", "bar" }, { "foo:/bar/", "foo:/", "bar" }, { "foo:/bar { "foo:/bar/.", "foo:/", "bar" }, { "foo:/bar/./", "foo:/", "bar" }, { "foo:/bar/..", "foo:/", "" }, { "foo:/bar/../", "foo:/", "" }, { "foo:/bar/baz", "foo:/bar/", "baz" }, { "foo:/bar/baz?bang", "foo:/bar/", "baz?bang" }, { "foo:/bar/baz/", "foo:/bar/", "baz" }, { "foo:/bar/baz/?bang", "foo:/bar/", "baz?bang" }, { "file: { "file: { "file: { "file:/foo/c%3A { "file: { "file:/c: { "file:/c%3A", "file:/", "c%3A" }, { "föö/", null, "föö" }, { "/föö", null, "föö" }, { " { " { "/föö/", null, "föö" }, { "/C%3A/", null, "C%3A" }, { "C%3A/", null, "C%3A" }, }) { FsNodePath path = FsNodePath.create(URI.create(params[0]), CANONICALIZE); final FsMountPoint mountPoint = null == params[1] ? null : FsMountPoint.create(URI.create(params[1])); final FsNodeName nodeName = FsNodeName.create(URI.create(params[2])); assertPath(path, mountPoint, nodeName); path = new FsNodePath(mountPoint, nodeName); assertPath(path, mountPoint, nodeName); } }
public static FsNodePath create(URI uri) { return create(uri, NULL); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); static FsNodePath create(URI uri); static FsNodePath create(URI uri, FsUriModifier modifier); URI getUri(); URI toHierarchicalUri(); @Nullable FsMountPoint getMountPoint(); FsNodeName getNodeName(); FsNodePath resolve(final FsNodeName nodeName); @Override int compareTo(FsNodePath that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public static FsNodePath create(URI uri) { return create(uri, NULL); } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); static FsNodePath create(URI uri); static FsNodePath create(URI uri, FsUriModifier modifier); URI getUri(); URI toHierarchicalUri(); @Nullable FsMountPoint getMountPoint(); FsNodeName getNodeName(); FsNodePath resolve(final FsNodeName nodeName); @Override int compareTo(FsNodePath that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
@Test public void testToHierarchicalUri() { for (final String[] params : new String[][] { { "foo:bar:baz:/x/bö%20m?plö%20k!/bä%20g?zö%20k!/", "baz:/x/bö%20m/bä%20g?zö%20k" }, { "bar:baz:/x/bö%20m?plö%20k!/bä%20g?zö%20k", "baz:/x/bö%20m/bä%20g?zö%20k" }, { "foo:bar:baz:/x/bööm?plönk!/bäng?zönk!/", "baz:/x/bööm/bäng?zönk" }, { "bar:baz:/x/bööm?plönk!/bäng?zönk", "baz:/x/bööm/bäng?zönk" }, { "foo:bar:baz:/boom?plonk!/bang?zonk!/", "baz:/boom/bang?zonk" }, { "bar:baz:/boom?plonk!/bang?zonk", "baz:/boom/bang?zonk" }, { "bar:baz:/boom?plonk!/?zonk", "baz:/boom/?zonk" }, { "bar:baz:/boom?plonk!/bang", "baz:/boom/bang" }, { "bar:baz:/boom?plonk!/", "baz:/boom?plonk" }, { "foo:bar:baz:/boom!/bang!/", "baz:/boom/bang" }, { "bar:baz:/boom!/bang", "baz:/boom/bang" }, { "foo:bar:/baz?boom!/", "bar:/baz?boom" }, { "bar:/baz?boom", "bar:/baz?boom" }, { "foo:bar:/baz!/", "bar:/baz" }, { "bar:/baz", "bar:/baz" }, { "foo:/bar/?boom", "foo:/bar/?boom" }, { "bar?boom", "bar?boom" }, { "foo:/bar/", "foo:/bar/" }, { "bar", "bar" }, }) { final FsNodePath path = FsNodePath.create(URI.create(params[0])); final URI hierarchical = path.toHierarchicalUri(); assertThat(hierarchical, equalTo(URI.create(params[1]))); } }
public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; if (null != hierarchical) return hierarchical; if (uri.isOpaque()) { final URI mpu = mountPoint.toHierarchicalUri(); final URI enu = nodeName.getUri(); try { return this.hierarchical = enu.toString().isEmpty() ? mpu : new UriBuilder(mpu, true) .path(mpu.getRawPath() + FsNodeName.SEPARATOR) .getUri() .resolve(enu); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } else { return this.hierarchical = uri; } }
FsNodePath implements Serializable, Comparable<FsNodePath> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; if (null != hierarchical) return hierarchical; if (uri.isOpaque()) { final URI mpu = mountPoint.toHierarchicalUri(); final URI enu = nodeName.getUri(); try { return this.hierarchical = enu.toString().isEmpty() ? mpu : new UriBuilder(mpu, true) .path(mpu.getRawPath() + FsNodeName.SEPARATOR) .getUri() .resolve(enu); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } else { return this.hierarchical = uri; } } }
FsNodePath implements Serializable, Comparable<FsNodePath> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; if (null != hierarchical) return hierarchical; if (uri.isOpaque()) { final URI mpu = mountPoint.toHierarchicalUri(); final URI enu = nodeName.getUri(); try { return this.hierarchical = enu.toString().isEmpty() ? mpu : new UriBuilder(mpu, true) .path(mpu.getRawPath() + FsNodeName.SEPARATOR) .getUri() .resolve(enu); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } else { return this.hierarchical = uri; } } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; if (null != hierarchical) return hierarchical; if (uri.isOpaque()) { final URI mpu = mountPoint.toHierarchicalUri(); final URI enu = nodeName.getUri(); try { return this.hierarchical = enu.toString().isEmpty() ? mpu : new UriBuilder(mpu, true) .path(mpu.getRawPath() + FsNodeName.SEPARATOR) .getUri() .resolve(enu); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } else { return this.hierarchical = uri; } } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); static FsNodePath create(URI uri); static FsNodePath create(URI uri, FsUriModifier modifier); URI getUri(); URI toHierarchicalUri(); @Nullable FsMountPoint getMountPoint(); FsNodeName getNodeName(); FsNodePath resolve(final FsNodeName nodeName); @Override int compareTo(FsNodePath that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsNodePath implements Serializable, Comparable<FsNodePath> { public URI toHierarchicalUri() { final URI hierarchical = this.hierarchical; if (null != hierarchical) return hierarchical; if (uri.isOpaque()) { final URI mpu = mountPoint.toHierarchicalUri(); final URI enu = nodeName.getUri(); try { return this.hierarchical = enu.toString().isEmpty() ? mpu : new UriBuilder(mpu, true) .path(mpu.getRawPath() + FsNodeName.SEPARATOR) .getUri() .resolve(enu); } catch (URISyntaxException ex) { throw new AssertionError(ex); } } else { return this.hierarchical = uri; } } FsNodePath(File file); @ConstructorProperties("uri") FsNodePath(URI uri); FsNodePath(URI uri, FsUriModifier modifier); FsNodePath( final @CheckForNull FsMountPoint mountPoint, final FsNodeName nodeName); static FsNodePath create(URI uri); static FsNodePath create(URI uri, FsUriModifier modifier); URI getUri(); URI toHierarchicalUri(); @Nullable FsMountPoint getMountPoint(); FsNodeName getNodeName(); FsNodePath resolve(final FsNodeName nodeName); @Override int compareTo(FsNodePath that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
@Test @SuppressWarnings("ResultOfObjectAllocationIgnored") public void testConstructorWithInvalidUri() { for (final String param : new String[] { "/../foo#boo", "/../foo#", "/../foo", "/./foo", " "/foo", "/foo/bar", "/foo/bar/", "/", "foo#fragmentDefined", "foo/", "foo "foo/.", "foo/./", "foo/..", "foo/../", "foo:bar", "foo:bar:", "foo:bar:/", "foo:bar:/baz", "foo:bar:/baz!", "foo:bar:/baz/", "foo:bar:/baz! "foo:bar:/baz!/#", "foo:bar:/baz!/#bang", "foo:bar:/baz!/.", "foo:bar:/baz!/./", "foo:bar:/baz!/..", "foo:bar:/baz!/../", "foo:bar:/baz!/bang/.", "foo:bar:/baz!/bang/./", "foo:bar:/baz!/bang/..", "foo:bar:/baz!/bang/../", "foo:bar:baz:/bang", "foo:bar:baz:/bang!", "foo:bar:baz:/bang/", "foo:bar:baz:/bang!/", "foo:bar:baz:/bang!/boom", "foo:bar:/baz/.!/", "foo:bar:/baz/./!/", "foo:bar:/baz/..!/", "foo:bar:/baz/../!/", "foo:bar:/baz/../!/bang/", "foo:bar:/baz/..!/bang/", "foo:bar:/baz/./!/bang/", "foo:bar:/baz/.!/bang/", "foo:bar:/../baz/!/bang/", "foo:bar:/./baz/!/bang/", "foo:bar: "foo:bar: "foo:bar:/!/bang/", "foo:bar:/baz/../!/bang", "foo:bar:/baz/..!/bang", "foo:bar:/baz/./!/bang", "foo:bar:/baz/.!/bang", "foo:bar:/../baz/!/bang", "foo:bar:/./baz/!/bang", "foo:bar: "foo:bar: "foo:bar:/!/bang", "foo:bar:/baz/!/", "foo:bar:/baz/?bang!/?plonk", "foo:bar:/baz "foo:bar:/baz/./!/", "foo:bar:/baz/..!/", "foo:bar:/baz/../!/", " }) { final URI uri = URI.create(param); try { FsNodeName.create(uri); fail(param); } catch (IllegalArgumentException ignored) { } try { new FsNodeName(uri); fail(param); } catch (URISyntaxException ignored) { } } }
public static FsNodeName create(URI uri) { return create(uri, NULL); }
FsNodeName implements Serializable, Comparable<FsNodeName> { public static FsNodeName create(URI uri) { return create(uri, NULL); } }
FsNodeName implements Serializable, Comparable<FsNodeName> { public static FsNodeName create(URI uri) { return create(uri, NULL); } @ConstructorProperties("uri") FsNodeName(URI uri); FsNodeName(URI uri, final FsUriModifier modifier); FsNodeName( final FsNodeName parent, final FsNodeName member); }
FsNodeName implements Serializable, Comparable<FsNodeName> { public static FsNodeName create(URI uri) { return create(uri, NULL); } @ConstructorProperties("uri") FsNodeName(URI uri); FsNodeName(URI uri, final FsUriModifier modifier); FsNodeName( final FsNodeName parent, final FsNodeName member); static FsNodeName create(URI uri); static FsNodeName create(URI uri, FsUriModifier modifier); boolean isRoot(); URI getUri(); String getPath(); @CheckForNull String getQuery(); @Override int compareTo(FsNodeName that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsNodeName implements Serializable, Comparable<FsNodeName> { public static FsNodeName create(URI uri) { return create(uri, NULL); } @ConstructorProperties("uri") FsNodeName(URI uri); FsNodeName(URI uri, final FsUriModifier modifier); FsNodeName( final FsNodeName parent, final FsNodeName member); static FsNodeName create(URI uri); static FsNodeName create(URI uri, FsUriModifier modifier); boolean isRoot(); URI getUri(); String getPath(); @CheckForNull String getQuery(); @Override int compareTo(FsNodeName that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); static final String SEPARATOR; static final char SEPARATOR_CHAR; static final FsNodeName ROOT; }
@Test public void testIsRoot() { for (final Object params[] : new Object[][] { { "", true }, { "?", false, }, }) { assertThat(FsNodeName.create(URI.create(params[0].toString())).isRoot(), is(params[1])); } }
public boolean isRoot() { final URI uri = getUri(); final String path = uri.getRawPath(); if (null != path && !path.isEmpty()) return false; final String query = uri.getRawQuery(); return null == query; }
FsNodeName implements Serializable, Comparable<FsNodeName> { public boolean isRoot() { final URI uri = getUri(); final String path = uri.getRawPath(); if (null != path && !path.isEmpty()) return false; final String query = uri.getRawQuery(); return null == query; } }
FsNodeName implements Serializable, Comparable<FsNodeName> { public boolean isRoot() { final URI uri = getUri(); final String path = uri.getRawPath(); if (null != path && !path.isEmpty()) return false; final String query = uri.getRawQuery(); return null == query; } @ConstructorProperties("uri") FsNodeName(URI uri); FsNodeName(URI uri, final FsUriModifier modifier); FsNodeName( final FsNodeName parent, final FsNodeName member); }
FsNodeName implements Serializable, Comparable<FsNodeName> { public boolean isRoot() { final URI uri = getUri(); final String path = uri.getRawPath(); if (null != path && !path.isEmpty()) return false; final String query = uri.getRawQuery(); return null == query; } @ConstructorProperties("uri") FsNodeName(URI uri); FsNodeName(URI uri, final FsUriModifier modifier); FsNodeName( final FsNodeName parent, final FsNodeName member); static FsNodeName create(URI uri); static FsNodeName create(URI uri, FsUriModifier modifier); boolean isRoot(); URI getUri(); String getPath(); @CheckForNull String getQuery(); @Override int compareTo(FsNodeName that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsNodeName implements Serializable, Comparable<FsNodeName> { public boolean isRoot() { final URI uri = getUri(); final String path = uri.getRawPath(); if (null != path && !path.isEmpty()) return false; final String query = uri.getRawQuery(); return null == query; } @ConstructorProperties("uri") FsNodeName(URI uri); FsNodeName(URI uri, final FsUriModifier modifier); FsNodeName( final FsNodeName parent, final FsNodeName member); static FsNodeName create(URI uri); static FsNodeName create(URI uri, FsUriModifier modifier); boolean isRoot(); URI getUri(); String getPath(); @CheckForNull String getQuery(); @Override int compareTo(FsNodeName that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); static final String SEPARATOR; static final char SEPARATOR_CHAR; static final FsNodeName ROOT; }
@Test @SuppressWarnings("ResultOfObjectAllocationIgnored") public void testConstructorWithInvalidUri() throws URISyntaxException { try { FsMountPoint.create((URI) null); fail(); } catch (NullPointerException expected) { } try { new FsMountPoint((URI) null); fail(); } catch (NullPointerException expected) { } try { FsMountPoint.create((URI) null, NULL); fail(); } catch (NullPointerException expected) { } try { new FsMountPoint((URI) null, NULL); fail(); } catch (NullPointerException expected) { } try { FsMountPoint.create((URI) null, CANONICALIZE); fail(); } catch (NullPointerException expected) { } try { new FsMountPoint((URI) null, CANONICALIZE); fail(); } catch (NullPointerException expected) { } try { FsMountPoint.create((FsScheme) null, null); fail(); } catch (NullPointerException expected) { } try { new FsMountPoint((FsScheme) null, null); fail(); } catch (NullPointerException expected) { } for (final String param : new String[] { "foo:/?queryDefined", "foo:bar:baz:/!/!/", "foo", "foo/bar", "foo/bar/", "/foo", "/foo/bar", "/foo/bar/", " "/../foo", "foo:/bar#baz", "foo:/bar/#baz", "foo:/bar", "foo:/bar?baz", "foo:/bar "foo:/bar/.", "foo:/bar/./", "foo:/bar/..", "foo:/bar/../", "foo:bar!/", "foo:bar:baz!/", "foo:bar:/baz! "foo:bar:/baz!/.", "foo:bar:/baz!/./", "foo:bar:/baz!/..", "foo:bar:/baz!/../", "foo:bar:/baz!/bang", "foo:bar:/baz!/#bang", "foo:bar:/baz/!/", "foo:bar:baz:/bang!/!/", }) { final URI uri = URI.create(param); try { FsMountPoint.create(uri); fail(param); } catch (IllegalArgumentException expected) { } try { new FsMountPoint(uri); fail(param); } catch (URISyntaxException expected) { } } for (final String[] params : new String[][] { { "foo", "bar:baz:/bang!/" }, { "foo", "bar:/baz/" }, }) { final FsScheme scheme = FsScheme.create(params[0]); final FsNodePath path = FsNodePath.create(URI.create(params[1])); try { new FsMountPoint(scheme, path); fail(params[0] + ":" + params[1] + "!/"); } catch (URISyntaxException expected) { } } }
public static FsMountPoint create(URI uri) { return create(uri, NULL); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public static FsMountPoint create(URI uri) { return create(uri, NULL); } }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public static FsMountPoint create(URI uri) { return create(uri, NULL); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public static FsMountPoint create(URI uri) { return create(uri, NULL); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); static FsMountPoint create(URI uri); static FsMountPoint create(URI uri, FsUriModifier modifier); static FsMountPoint create(FsScheme scheme, FsNodePath path); URI getUri(); URI toHierarchicalUri(); FsScheme getScheme(); @Nullable FsNodePath getPath(); @Nullable FsMountPoint getParent(); FsNodePath resolve(FsNodeName name); @Override int compareTo(FsMountPoint that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public static FsMountPoint create(URI uri) { return create(uri, NULL); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); static FsMountPoint create(URI uri); static FsMountPoint create(URI uri, FsUriModifier modifier); static FsMountPoint create(FsScheme scheme, FsNodePath path); URI getUri(); URI toHierarchicalUri(); FsScheme getScheme(); @Nullable FsNodePath getPath(); @Nullable FsMountPoint getParent(); FsNodePath resolve(FsNodeName name); @Override int compareTo(FsMountPoint that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); static final String SEPARATOR; }
@Test public void testResolve() { for (final String[] params : new String[][] { { "foo:bar:/baz?plonk!/", "", "baz", "foo:bar:/baz?plonk!/" }, { "foo:bar:/bäz?bööm!/", "bäng?plönk", "bäz/bäng?plönk", "foo:bar:/bäz?bööm!/bäng?plönk" }, { "foo:bar:/baz!/", "bang?boom", "baz/bang?boom", "foo:bar:/baz!/bang?boom" }, { "foo:bar:/baz!/", "bang", "baz/bang", "foo:bar:/baz!/bang" }, { "foo:bar:/baz!/", "", "baz", "foo:bar:/baz!/" }, { "foo:bar:/baz?plonk!/", "bang?boom", "baz/bang?boom", "foo:bar:/baz?plonk!/bang?boom" }, { "foo:bar:/baz?plonk!/", "bang", "baz/bang", "foo:bar:/baz?plonk!/bang" }, { "foo:/bar/", "baz?bang", null, "foo:/bar/baz?bang" }, { "foo:/bar/", "baz", null, "foo:/bar/baz" }, { "foo:/bar/", "", null, "foo:/bar/" }, { "foo:/bar/", "baz", null, "foo:/bar/baz" }, }) { final FsMountPoint mountPoint = FsMountPoint.create(URI.create(params[0])); final FsNodeName entryName = FsNodeName.create(URI.create(params[1])); final FsNodeName parentEntryName = null == params[2] ? null : FsNodeName.create(URI.create(params[2])); final FsNodePath path = FsNodePath.create(URI.create(params[3])); if (null != parentEntryName) assertThat(mountPoint.getPath().resolve(entryName).getNodeName(), equalTo(parentEntryName)); assertThat(mountPoint.resolve(entryName), equalTo(path)); assertThat(mountPoint.resolve(entryName).getUri().isAbsolute(), is(true)); } }
public FsNodePath resolve(FsNodeName name) { return new FsNodePath(this, name); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public FsNodePath resolve(FsNodeName name) { return new FsNodePath(this, name); } }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public FsNodePath resolve(FsNodeName name) { return new FsNodePath(this, name); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public FsNodePath resolve(FsNodeName name) { return new FsNodePath(this, name); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); static FsMountPoint create(URI uri); static FsMountPoint create(URI uri, FsUriModifier modifier); static FsMountPoint create(FsScheme scheme, FsNodePath path); URI getUri(); URI toHierarchicalUri(); FsScheme getScheme(); @Nullable FsNodePath getPath(); @Nullable FsMountPoint getParent(); FsNodePath resolve(FsNodeName name); @Override int compareTo(FsMountPoint that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); }
FsMountPoint implements Serializable, Comparable<FsMountPoint> { public FsNodePath resolve(FsNodeName name) { return new FsNodePath(this, name); } @ConstructorProperties("uri") FsMountPoint(URI uri); FsMountPoint(URI uri, FsUriModifier modifier); FsMountPoint(final FsScheme scheme, final FsNodePath path); static FsMountPoint create(URI uri); static FsMountPoint create(URI uri, FsUriModifier modifier); static FsMountPoint create(FsScheme scheme, FsNodePath path); URI getUri(); URI toHierarchicalUri(); FsScheme getScheme(); @Nullable FsNodePath getPath(); @Nullable FsMountPoint getParent(); FsNodePath resolve(FsNodeName name); @Override int compareTo(FsMountPoint that); @Override boolean equals(@CheckForNull Object that); @Override int hashCode(); @Override String toString(); static final String SEPARATOR; }
@Test public void testUser() { String login = "carl"; String password = "mypassword"; String email = "[email protected]"; User user = User.builder().login(login).password(password).email(email).build(); assertEquals(login, user.getLogin()); assertEquals(email, user.getEmail()); }
public User(final String login, final String password) { this.login = login; this.password = password; }
User implements Serializable { public User(final String login, final String password) { this.login = login; this.password = password; } }
User implements Serializable { public User(final String login, final String password) { this.login = login; this.password = password; } User(final String login, final String password); }
User implements Serializable { public User(final String login, final String password) { this.login = login; this.password = password; } User(final String login, final String password); final void setLocale(final String locale); final Date getLastUpdate(); final void setLastUpdate(final Date lastUpdate); final void setDatePattern(final String datePattern); final String getLanguage(); final String getCountry(); final JsonObject getJSONObject(); }
User implements Serializable { public User(final String login, final String password) { this.login = login; this.password = password; } User(final String login, final String password); final void setLocale(final String locale); final Date getLastUpdate(); final void setLastUpdate(final Date lastUpdate); final void setDatePattern(final String datePattern); final String getLanguage(); final String getCountry(); final JsonObject getJSONObject(); }
@Test public void testGetAccountByName() { portfolio.setAccounts(createAccounts()); Optional<Account> actual = portfolio.getAccount(FIDELITY); assertTrue(actual.isPresent()); }
public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetAccountById() { portfolio.setAccounts(createAccounts()); Optional<Account> actual = portfolio.getAccount(2); assertTrue(actual.isPresent()); }
public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetAccountByIdEmpty() { Optional<Account> actual = portfolio.getAccount(2); assertFalse(actual.isPresent()); }
public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final Optional<Account> getAccount(final String name) { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> account.getName().equals(name)).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetFirstAccount() { portfolio.setAccounts(createAccounts()); Optional<Account> actual = portfolio.getFirstAccount(); assertTrue(actual.isPresent()); }
public final Optional<Account> getFirstAccount() { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> !account.getDel()).findFirst(); }
Portfolio { public final Optional<Account> getFirstAccount() { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> !account.getDel()).findFirst(); } }
Portfolio { public final Optional<Account> getFirstAccount() { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> !account.getDel()).findFirst(); } Portfolio(); }
Portfolio { public final Optional<Account> getFirstAccount() { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> !account.getDel()).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final Optional<Account> getFirstAccount() { return accounts == null ? Optional.empty() : accounts.stream().filter(account -> !account.getDel()).findFirst(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetSectorByCompanies() { portfolio.setEquities(createEquities()); Map<String, List<Equity>> actual = portfolio.getSectorByCompanies(); assertNotNull(actual); assertThat(actual.size(), is(3)); assertTrue(actual.containsKey(FUND)); assertTrue(actual.containsKey(UNKNOWN)); assertTrue(actual.containsKey(HIGH_TECH)); }
protected Map<String, List<Equity>> getSectorByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { companies = map.getOrDefault(Constants.FUND, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.FUND, companies); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { companies = map.getOrDefault(Constants.UNKNOWN, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.UNKNOWN, companies); } else { companies = map.getOrDefault(sector, new ArrayList<>()); companies.add(equity); map.putIfAbsent(sector, companies); } } } return map; }
Portfolio { protected Map<String, List<Equity>> getSectorByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { companies = map.getOrDefault(Constants.FUND, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.FUND, companies); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { companies = map.getOrDefault(Constants.UNKNOWN, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.UNKNOWN, companies); } else { companies = map.getOrDefault(sector, new ArrayList<>()); companies.add(equity); map.putIfAbsent(sector, companies); } } } return map; } }
Portfolio { protected Map<String, List<Equity>> getSectorByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { companies = map.getOrDefault(Constants.FUND, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.FUND, companies); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { companies = map.getOrDefault(Constants.UNKNOWN, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.UNKNOWN, companies); } else { companies = map.getOrDefault(sector, new ArrayList<>()); companies.add(equity); map.putIfAbsent(sector, companies); } } } return map; } Portfolio(); }
Portfolio { protected Map<String, List<Equity>> getSectorByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { companies = map.getOrDefault(Constants.FUND, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.FUND, companies); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { companies = map.getOrDefault(Constants.UNKNOWN, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.UNKNOWN, companies); } else { companies = map.getOrDefault(sector, new ArrayList<>()); companies.add(equity); map.putIfAbsent(sector, companies); } } } return map; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { protected Map<String, List<Equity>> getSectorByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { companies = map.getOrDefault(Constants.FUND, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.FUND, companies); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { companies = map.getOrDefault(Constants.UNKNOWN, new ArrayList<>()); companies.add(equity); map.putIfAbsent(Constants.UNKNOWN, companies); } else { companies = map.getOrDefault(sector, new ArrayList<>()); companies.add(equity); map.putIfAbsent(sector, companies); } } } return map; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetHTMLSectorByCompanies() { portfolio.setEquities(createEquities()); String actual = portfolio.getHTMLSectorByCompanies(); verifyHTML(actual); }
public final String getHTMLSectorByCompanies() { final Map<String, List<Equity>> map = getSectorByCompanies(); return extractHTMLfromMap(map); }
Portfolio { public final String getHTMLSectorByCompanies() { final Map<String, List<Equity>> map = getSectorByCompanies(); return extractHTMLfromMap(map); } }
Portfolio { public final String getHTMLSectorByCompanies() { final Map<String, List<Equity>> map = getSectorByCompanies(); return extractHTMLfromMap(map); } Portfolio(); }
Portfolio { public final String getHTMLSectorByCompanies() { final Map<String, List<Equity>> map = getSectorByCompanies(); return extractHTMLfromMap(map); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final String getHTMLSectorByCompanies() { final Map<String, List<Equity>> map = getSectorByCompanies(); return extractHTMLfromMap(map); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetGapByCompanies() { portfolio.setEquities(createEquities()); Map<String, List<Equity>> actual = portfolio.getGapByCompanies(); assertNotNull(actual); assertThat(actual.size(), is(3)); assertTrue(actual.containsKey(LARGE_CAP.getValue())); assertTrue(actual.containsKey(MEGA_CAP.getValue())); assertTrue(actual.containsKey(UNKNOWN)); }
protected Map<String, List<Equity>> getGapByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getMarketCapitalizationType().getValue() == null || equity.getCompany().getFund()) { equity.setMarketCapitalizationType(MarketCapitalization.UNKNOWN); } companies = map.getOrDefault(equity.getMarketCapitalizationType().getValue(), new ArrayList<>()); companies.add(equity); map.put(equity.getMarketCapitalizationType().getValue(), companies); } return map; }
Portfolio { protected Map<String, List<Equity>> getGapByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getMarketCapitalizationType().getValue() == null || equity.getCompany().getFund()) { equity.setMarketCapitalizationType(MarketCapitalization.UNKNOWN); } companies = map.getOrDefault(equity.getMarketCapitalizationType().getValue(), new ArrayList<>()); companies.add(equity); map.put(equity.getMarketCapitalizationType().getValue(), companies); } return map; } }
Portfolio { protected Map<String, List<Equity>> getGapByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getMarketCapitalizationType().getValue() == null || equity.getCompany().getFund()) { equity.setMarketCapitalizationType(MarketCapitalization.UNKNOWN); } companies = map.getOrDefault(equity.getMarketCapitalizationType().getValue(), new ArrayList<>()); companies.add(equity); map.put(equity.getMarketCapitalizationType().getValue(), companies); } return map; } Portfolio(); }
Portfolio { protected Map<String, List<Equity>> getGapByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getMarketCapitalizationType().getValue() == null || equity.getCompany().getFund()) { equity.setMarketCapitalizationType(MarketCapitalization.UNKNOWN); } companies = map.getOrDefault(equity.getMarketCapitalizationType().getValue(), new ArrayList<>()); companies.add(equity); map.put(equity.getMarketCapitalizationType().getValue(), companies); } return map; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { protected Map<String, List<Equity>> getGapByCompanies() { final Map<String, List<Equity>> map = new TreeMap<>(); List<Equity> companies; for (final Equity equity : getEquities()) { if (equity.getMarketCapitalizationType().getValue() == null || equity.getCompany().getFund()) { equity.setMarketCapitalizationType(MarketCapitalization.UNKNOWN); } companies = map.getOrDefault(equity.getMarketCapitalizationType().getValue(), new ArrayList<>()); companies.add(equity); map.put(equity.getMarketCapitalizationType().getValue(), companies); } return map; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetHTMLCapByCompanies() { portfolio.setEquities(createEquities()); String actual = portfolio.getHTMLCapByCompanies(); verifyHTML(actual); }
public final String getHTMLCapByCompanies() { final Map<String, List<Equity>> map = getGapByCompanies(); return extractHTMLfromMap(map); }
Portfolio { public final String getHTMLCapByCompanies() { final Map<String, List<Equity>> map = getGapByCompanies(); return extractHTMLfromMap(map); } }
Portfolio { public final String getHTMLCapByCompanies() { final Map<String, List<Equity>> map = getGapByCompanies(); return extractHTMLfromMap(map); } Portfolio(); }
Portfolio { public final String getHTMLCapByCompanies() { final Map<String, List<Equity>> map = getGapByCompanies(); return extractHTMLfromMap(map); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final String getHTMLCapByCompanies() { final Map<String, List<Equity>> map = getGapByCompanies(); return extractHTMLfromMap(map); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetTotalValue() { Double actual = portfolio.getTotalValue(); assertEquals(0d, actual, 0.1); }
public final Double getTotalValue() { return totalValue + getLiquidity(); }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } Portfolio(); }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetTotalValueWithLiquidity() { portfolio.setLiquidity(1000d); Double actual = portfolio.getTotalValue(); assertEquals(1000d, actual, 0.1); }
public final Double getTotalValue() { return totalValue + getLiquidity(); }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } Portfolio(); }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final Double getTotalValue() { return totalValue + getLiquidity(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testCompute() { portfolio.setEquities(createEquities()); portfolio.compute(); assertEquals(66d, portfolio.getTotalQuantity(), 0.1); assertEquals(30500d, portfolio.getTotalValue(), 0.1); assertEquals(0d, portfolio.getYieldYear(), 0.1); assertEquals(12700d, portfolio.getTotalGain(), 0.1); assertNotNull(portfolio.getLastCompanyUpdate()); }
public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } Portfolio(); }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final void compute() { Double totalUnitCostPrice = 0d; Double totalAverageQuotePrice = 0d; Double totalOriginalValue = 0d; totalVariation = 0d; double totalValueStart = 0; totalGainToday = 0d; Date lastUpdate = null; if (equities != null) { for (final Equity equity : equities) { totalQuantity += equity.getQuantity(); totalUnitCostPrice += equity.getUnitCostPrice(); totalAverageQuotePrice += equity.getCompany().getQuote() * equity.getParity(); totalValue += equity.getValue(); totalOriginalValue += equity.getQuantity() * equity.getUnitCostPrice() * equity.getCurrentParity(); yieldYear += equity.getYieldYear(); totalGain += equity.getPlusMinusUnitCostPriceValue(); if (equity.getCompany().getRealTime()) { if (lastUpdate == null) { lastUpdate = equity.getCompany().getLastUpdate(); } else { if (equity.getCompany().getLastUpdate() != null && lastUpdate.after(equity.getCompany().getLastUpdate())) { lastUpdate = equity.getCompany().getLastUpdate(); } } } if (equity.getCompany().getChange() != null) { double valueStart = equity.getValue() / (equity.getCompany().getChange() / PERCENT + 1); totalValueStart += valueStart; totalGainToday += valueStart * equity.getCompany().getChange() / PERCENT; } } totalVariation = totalValueStart == 0 ? totalValueStart : ((totalValueStart + totalGainToday) / totalValueStart - 1) * PERCENT; averageUnitCostPrice = totalUnitCostPrice / equities.size(); averageQuotePrice = totalAverageQuotePrice / equities.size(); totalPlusMinusValue = ((totalValue - totalOriginalValue) / totalOriginalValue) * PERCENT; yieldYearPerc = yieldYear / getTotalValue() * PERCENT; setLastCompanyUpdate(lastUpdate); } } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetChartSectorData() { portfolio.setEquities(createEquities()); Map<String, Double> actual = portfolio.getChartSectorData(); assertNotNull(actual); assertEquals(25500d, actual.get(FUND), 0.1); assertEquals(4000d, actual.get(HIGH_TECH), 0.1); assertEquals(1000d, actual.get(UNKNOWN), 0.1); }
protected final Map<String, Double> getChartSectorData() { if (chartSectorData == null) { final Map<String, Double> data = new HashMap<>(); for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { addEquityValueToMap(data, Constants.FUND, equity); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, sector, equity); } } } chartSectorData = new TreeMap<>(); chartSectorData.putAll(data); } return chartSectorData; }
Portfolio { protected final Map<String, Double> getChartSectorData() { if (chartSectorData == null) { final Map<String, Double> data = new HashMap<>(); for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { addEquityValueToMap(data, Constants.FUND, equity); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, sector, equity); } } } chartSectorData = new TreeMap<>(); chartSectorData.putAll(data); } return chartSectorData; } }
Portfolio { protected final Map<String, Double> getChartSectorData() { if (chartSectorData == null) { final Map<String, Double> data = new HashMap<>(); for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { addEquityValueToMap(data, Constants.FUND, equity); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, sector, equity); } } } chartSectorData = new TreeMap<>(); chartSectorData.putAll(data); } return chartSectorData; } Portfolio(); }
Portfolio { protected final Map<String, Double> getChartSectorData() { if (chartSectorData == null) { final Map<String, Double> data = new HashMap<>(); for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { addEquityValueToMap(data, Constants.FUND, equity); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, sector, equity); } } } chartSectorData = new TreeMap<>(); chartSectorData.putAll(data); } return chartSectorData; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { protected final Map<String, Double> getChartSectorData() { if (chartSectorData == null) { final Map<String, Double> data = new HashMap<>(); for (final Equity equity : getEquities()) { if (equity.getCompany().getFund()) { addEquityValueToMap(data, Constants.FUND, equity); } else { final String sector = equity.getCurrentSector(); if (StringUtils.isEmpty(sector)) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, sector, equity); } } } chartSectorData = new TreeMap<>(); chartSectorData.putAll(data); } return chartSectorData; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetChartShareValueData() { portfolio.setShareValues(createShareValues()); Map<Date, Double> actual = portfolio.getChartShareValueData(); assertNotNull(actual); assertThat(actual.size(), is(2)); Iterator<Date> iterator = actual.keySet().iterator(); assertEquals(100d, actual.get(iterator.next()), 0.1); assertEquals(50d, actual.get(iterator.next()), 0.1); }
protected final Map<Date, Double> getChartShareValueData() { Map<Date, Double> data = new HashMap<>(); List<ShareValue> shareValuess = getShareValues(); int max = shareValuess.size(); double base = shareValuess.get(max - 1).getShareValue(); for (int i = max - 1; i != -1; i--) { ShareValue temp = shareValuess.get(i); Double value = temp.getShareValue() * PERCENT / base; data.put(temp.getDate(), value); } chartShareValueData = new TreeMap<>(); chartShareValueData.putAll(data); return chartShareValueData; }
Portfolio { protected final Map<Date, Double> getChartShareValueData() { Map<Date, Double> data = new HashMap<>(); List<ShareValue> shareValuess = getShareValues(); int max = shareValuess.size(); double base = shareValuess.get(max - 1).getShareValue(); for (int i = max - 1; i != -1; i--) { ShareValue temp = shareValuess.get(i); Double value = temp.getShareValue() * PERCENT / base; data.put(temp.getDate(), value); } chartShareValueData = new TreeMap<>(); chartShareValueData.putAll(data); return chartShareValueData; } }
Portfolio { protected final Map<Date, Double> getChartShareValueData() { Map<Date, Double> data = new HashMap<>(); List<ShareValue> shareValuess = getShareValues(); int max = shareValuess.size(); double base = shareValuess.get(max - 1).getShareValue(); for (int i = max - 1; i != -1; i--) { ShareValue temp = shareValuess.get(i); Double value = temp.getShareValue() * PERCENT / base; data.put(temp.getDate(), value); } chartShareValueData = new TreeMap<>(); chartShareValueData.putAll(data); return chartShareValueData; } Portfolio(); }
Portfolio { protected final Map<Date, Double> getChartShareValueData() { Map<Date, Double> data = new HashMap<>(); List<ShareValue> shareValuess = getShareValues(); int max = shareValuess.size(); double base = shareValuess.get(max - 1).getShareValue(); for (int i = max - 1; i != -1; i--) { ShareValue temp = shareValuess.get(i); Double value = temp.getShareValue() * PERCENT / base; data.put(temp.getDate(), value); } chartShareValueData = new TreeMap<>(); chartShareValueData.putAll(data); return chartShareValueData; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { protected final Map<Date, Double> getChartShareValueData() { Map<Date, Double> data = new HashMap<>(); List<ShareValue> shareValuess = getShareValues(); int max = shareValuess.size(); double base = shareValuess.get(max - 1).getShareValue(); for (int i = max - 1; i != -1; i--) { ShareValue temp = shareValuess.get(i); Double value = temp.getShareValue() * PERCENT / base; data.put(temp.getDate(), value); } chartShareValueData = new TreeMap<>(); chartShareValueData.putAll(data); return chartShareValueData; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetChartCapData() { portfolio.setEquities(createEquities()); Map<String, Double> actual = portfolio.getChartCapData(); assertNotNull(actual); assertEquals(1000d, actual.get(MEGA_CAP.getValue()), 0.1); assertEquals(4000d, actual.get(LARGE_CAP.getValue()), 0.1); assertEquals(25500d, actual.get(UNKNOWN), 0.1); }
protected final Map<String, Double> getChartCapData() { if (chartCapData == null) { Map<String, Double> data = new HashMap<>(); for (Equity equity : getEquities()) { if (!equity.getCompany().getFund()) { MarketCapitalization marketCap = equity.getMarketCapitalizationType(); if (marketCap == null) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, marketCap.getValue(), equity); } } else { addEquityValueToMap(data, Constants.UNKNOWN, equity); } } chartCapData = new TreeMap<>(); chartCapData.putAll(data); } return chartCapData; }
Portfolio { protected final Map<String, Double> getChartCapData() { if (chartCapData == null) { Map<String, Double> data = new HashMap<>(); for (Equity equity : getEquities()) { if (!equity.getCompany().getFund()) { MarketCapitalization marketCap = equity.getMarketCapitalizationType(); if (marketCap == null) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, marketCap.getValue(), equity); } } else { addEquityValueToMap(data, Constants.UNKNOWN, equity); } } chartCapData = new TreeMap<>(); chartCapData.putAll(data); } return chartCapData; } }
Portfolio { protected final Map<String, Double> getChartCapData() { if (chartCapData == null) { Map<String, Double> data = new HashMap<>(); for (Equity equity : getEquities()) { if (!equity.getCompany().getFund()) { MarketCapitalization marketCap = equity.getMarketCapitalizationType(); if (marketCap == null) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, marketCap.getValue(), equity); } } else { addEquityValueToMap(data, Constants.UNKNOWN, equity); } } chartCapData = new TreeMap<>(); chartCapData.putAll(data); } return chartCapData; } Portfolio(); }
Portfolio { protected final Map<String, Double> getChartCapData() { if (chartCapData == null) { Map<String, Double> data = new HashMap<>(); for (Equity equity : getEquities()) { if (!equity.getCompany().getFund()) { MarketCapitalization marketCap = equity.getMarketCapitalizationType(); if (marketCap == null) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, marketCap.getValue(), equity); } } else { addEquityValueToMap(data, Constants.UNKNOWN, equity); } } chartCapData = new TreeMap<>(); chartCapData.putAll(data); } return chartCapData; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { protected final Map<String, Double> getChartCapData() { if (chartCapData == null) { Map<String, Double> data = new HashMap<>(); for (Equity equity : getEquities()) { if (!equity.getCompany().getFund()) { MarketCapitalization marketCap = equity.getMarketCapitalizationType(); if (marketCap == null) { addEquityValueToMap(data, Constants.UNKNOWN, equity); } else { addEquityValueToMap(data, marketCap.getValue(), equity); } } else { addEquityValueToMap(data, Constants.UNKNOWN, equity); } } chartCapData = new TreeMap<>(); chartCapData.putAll(data); } return chartCapData; } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetCompaniesYahooIdRealTime() { portfolio.setEquities(createEquities()); List<String> actual = portfolio.getCompaniesYahooIdRealTime(); assertNotNull(actual); assertThat(actual, containsInAnyOrder(GOOGLE, APPLE)); }
public final List<String> getCompaniesYahooIdRealTime() { return getEquities().stream() .filter(equity -> equity.getCompany().getRealTime()) .map(equity -> equity.getCompany().getYahooId()) .collect(Collectors.toList()); }
Portfolio { public final List<String> getCompaniesYahooIdRealTime() { return getEquities().stream() .filter(equity -> equity.getCompany().getRealTime()) .map(equity -> equity.getCompany().getYahooId()) .collect(Collectors.toList()); } }
Portfolio { public final List<String> getCompaniesYahooIdRealTime() { return getEquities().stream() .filter(equity -> equity.getCompany().getRealTime()) .map(equity -> equity.getCompany().getYahooId()) .collect(Collectors.toList()); } Portfolio(); }
Portfolio { public final List<String> getCompaniesYahooIdRealTime() { return getEquities().stream() .filter(equity -> equity.getCompany().getRealTime()) .map(equity -> equity.getCompany().getYahooId()) .collect(Collectors.toList()); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final List<String> getCompaniesYahooIdRealTime() { return getEquities().stream() .filter(equity -> equity.getCompany().getRealTime()) .map(equity -> equity.getCompany().getYahooId()) .collect(Collectors.toList()); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testAddIndexes() { final List<Index> indexes = new ArrayList<>(); final Index index = Index.builder().yahooId(CAC40).build(); indexes.add(index); portfolio.addIndexes(indexes); final Map<String, List<Index>> actual = portfolio.getIndexes(); assertNotNull(actual); assertThat(actual.size(), is(1)); assertNotNull(actual.get(CAC40)); }
public final void addIndexes(final List<Index> indexes) { if (indexes.size() > 0) { String index = indexes.get(0).getYahooId(); this.indexes.put(index, indexes); } }
Portfolio { public final void addIndexes(final List<Index> indexes) { if (indexes.size() > 0) { String index = indexes.get(0).getYahooId(); this.indexes.put(index, indexes); } } }
Portfolio { public final void addIndexes(final List<Index> indexes) { if (indexes.size() > 0) { String index = indexes.get(0).getYahooId(); this.indexes.put(index, indexes); } } Portfolio(); }
Portfolio { public final void addIndexes(final List<Index> indexes) { if (indexes.size() > 0) { String index = indexes.get(0).getYahooId(); this.indexes.put(index, indexes); } } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final void addIndexes(final List<Index> indexes) { if (indexes.size() > 0) { String index = indexes.get(0).getYahooId(); this.indexes.put(index, indexes); } } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testGetPortfolioReview() { portfolio.setEquities(createEquities()); final String actual = portfolio.getPortfolioReview(); assertNotNull(actual); }
public final String getPortfolioReview() { final StringBuilder sb = new StringBuilder(); sb.append("<table class=\"shareValueTableDetails\">"); for (final Equity equity : getEquities()) { sb.append("<tr><td width=200px><b>") .append(equity.getCurrentName()) .append("</b></td><td width=180px>") .append(equity.getQuantity()) .append(" * ") .append(equity.getCompany().getQuote()); if (equity.getCompany().getCurrency() != getCurrency()) { sb.append(" * ").append(getCurrency().getParity(equity.getCompany().getCurrency())); } sb.append("</td><td>").append(equity.getValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); } sb.append("<tr><td colspan=3><b>Liquidity:</b> ").append(getLiquidity()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("<tr><td colspan=3><b>Total:</b> ").append(new BigDecimal(getTotalValue(), mathContext).doubleValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("</table>"); return sb.toString(); }
Portfolio { public final String getPortfolioReview() { final StringBuilder sb = new StringBuilder(); sb.append("<table class=\"shareValueTableDetails\">"); for (final Equity equity : getEquities()) { sb.append("<tr><td width=200px><b>") .append(equity.getCurrentName()) .append("</b></td><td width=180px>") .append(equity.getQuantity()) .append(" * ") .append(equity.getCompany().getQuote()); if (equity.getCompany().getCurrency() != getCurrency()) { sb.append(" * ").append(getCurrency().getParity(equity.getCompany().getCurrency())); } sb.append("</td><td>").append(equity.getValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); } sb.append("<tr><td colspan=3><b>Liquidity:</b> ").append(getLiquidity()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("<tr><td colspan=3><b>Total:</b> ").append(new BigDecimal(getTotalValue(), mathContext).doubleValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("</table>"); return sb.toString(); } }
Portfolio { public final String getPortfolioReview() { final StringBuilder sb = new StringBuilder(); sb.append("<table class=\"shareValueTableDetails\">"); for (final Equity equity : getEquities()) { sb.append("<tr><td width=200px><b>") .append(equity.getCurrentName()) .append("</b></td><td width=180px>") .append(equity.getQuantity()) .append(" * ") .append(equity.getCompany().getQuote()); if (equity.getCompany().getCurrency() != getCurrency()) { sb.append(" * ").append(getCurrency().getParity(equity.getCompany().getCurrency())); } sb.append("</td><td>").append(equity.getValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); } sb.append("<tr><td colspan=3><b>Liquidity:</b> ").append(getLiquidity()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("<tr><td colspan=3><b>Total:</b> ").append(new BigDecimal(getTotalValue(), mathContext).doubleValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("</table>"); return sb.toString(); } Portfolio(); }
Portfolio { public final String getPortfolioReview() { final StringBuilder sb = new StringBuilder(); sb.append("<table class=\"shareValueTableDetails\">"); for (final Equity equity : getEquities()) { sb.append("<tr><td width=200px><b>") .append(equity.getCurrentName()) .append("</b></td><td width=180px>") .append(equity.getQuantity()) .append(" * ") .append(equity.getCompany().getQuote()); if (equity.getCompany().getCurrency() != getCurrency()) { sb.append(" * ").append(getCurrency().getParity(equity.getCompany().getCurrency())); } sb.append("</td><td>").append(equity.getValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); } sb.append("<tr><td colspan=3><b>Liquidity:</b> ").append(getLiquidity()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("<tr><td colspan=3><b>Total:</b> ").append(new BigDecimal(getTotalValue(), mathContext).doubleValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("</table>"); return sb.toString(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
Portfolio { public final String getPortfolioReview() { final StringBuilder sb = new StringBuilder(); sb.append("<table class=\"shareValueTableDetails\">"); for (final Equity equity : getEquities()) { sb.append("<tr><td width=200px><b>") .append(equity.getCurrentName()) .append("</b></td><td width=180px>") .append(equity.getQuantity()) .append(" * ") .append(equity.getCompany().getQuote()); if (equity.getCompany().getCurrency() != getCurrency()) { sb.append(" * ").append(getCurrency().getParity(equity.getCompany().getCurrency())); } sb.append("</td><td>").append(equity.getValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); } sb.append("<tr><td colspan=3><b>Liquidity:</b> ").append(getLiquidity()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("<tr><td colspan=3><b>Total:</b> ").append(new BigDecimal(getTotalValue(), mathContext).doubleValue()).append(" (").append(getCurrency().getCode()).append(")</td></tr>"); sb.append("</table>"); return sb.toString(); } Portfolio(); final Double getTotalValue(); final Double getTotalPlusMinusValue(); final Double getTotalPlusMinusValueAbsolute(); final Double getYieldYear(); final Double getTotalGain(); final Double getYieldYearPerc(); final Date getLastCompanyUpdate(); final void setLastCompanyUpdate(final Date lastCompanyUpdate); final void compute(); final Double getTotalGainTodayAbsolute(); final List<String> getCompaniesYahooIdRealTime(); final void addIndexes(final List<Index> indexes); final String getPortfolioReview(); final IChart getPieChartSector(); final IChart getPieChartCap(); final IChart getTimeValueChart(); final IChart getTimeChart(); final Optional<Account> getAccount(final String name); final Optional<Account> getAccount(final int id); final Optional<Account> getFirstAccount(); final String getHTMLSectorByCompanies(); final String getHTMLCapByCompanies(); final Double getMaxShareValue(); final Date getMaxShareValueDate(); final Double getCurrentShareValuesYield(); final Double getCurrentShareValuesTaxes(); final Double getCurrentShareValuesVolume(); final Double getCurrenShareValuesGain(); final Double getCurrenShareValuesGainPorcentage(); final JsonObject getJSONObject(); }
@Test public void testKeyPairGeneration() throws Exception { KeyPair keyPair = TokenUtils.generateKeyPair(2048); PrivateKey privateKey = keyPair.getPrivate(); PublicKey publicKey = keyPair.getPublic(); byte[] privateKeyEnc = privateKey.getEncoded(); byte[] privateKeyPem = Base64.getEncoder().encode(privateKeyEnc); String privateKeyPemStr = new String(privateKeyPem); System.out.println("-----BEGIN RSA PRIVATE KEY-----"); int column = 0; for (int n = 0; n < privateKeyPemStr.length(); n++) { System.out.print(privateKeyPemStr.charAt(n)); column++; if (column == 64) { System.out.println(); column = 0; } } System.out.println("\n-----END RSA PRIVATE KEY-----"); byte[] publicKeyEnc = publicKey.getEncoded(); byte[] publicKeyPem = Base64.getEncoder().encode(publicKeyEnc); String publicKeyPemStr = new String(publicKeyPem); System.out.println("-----BEGIN RSA PUBLIC KEY-----"); column = 0; for (int n = 0; n < publicKeyPemStr.length(); n++) { System.out.print(publicKeyPemStr.charAt(n)); column++; if (column == 64) { System.out.println(); column = 0; } } System.out.println("\n-----END RSA PUBLIC KEY-----"); }
public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(keySize); KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPair; }
TokenUtils { public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(keySize); KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPair; } }
TokenUtils { public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(keySize); KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPair; } private TokenUtils(); }
TokenUtils { public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(keySize); KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPair; } private TokenUtils(); static String generateTokenString(String jsonResName); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static PrivateKey readPrivateKey(String pemResName); static PublicKey readPublicKey(String pemResName); static KeyPair generateKeyPair(int keySize); static PrivateKey decodePrivateKey(String pemEncoded); static PublicKey decodePublicKey(String pemEncoded); }
TokenUtils { public static KeyPair generateKeyPair(int keySize) throws NoSuchAlgorithmException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(keySize); KeyPair keyPair = keyPairGenerator.genKeyPair(); return keyPair; } private TokenUtils(); static String generateTokenString(String jsonResName); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static PrivateKey readPrivateKey(String pemResName); static PublicKey readPublicKey(String pemResName); static KeyPair generateKeyPair(int keySize); static PrivateKey decodePrivateKey(String pemEncoded); static PublicKey decodePublicKey(String pemEncoded); }
@Test public void testReadPrivateKey() throws Exception { PrivateKey privateKey = TokenUtils.readPrivateKey("/privateKey.pem"); System.out.println(privateKey); }
public static PrivateKey readPrivateKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PrivateKey privateKey = decodePrivateKey(new String(tmp, 0, length)); return privateKey; }
TokenUtils { public static PrivateKey readPrivateKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PrivateKey privateKey = decodePrivateKey(new String(tmp, 0, length)); return privateKey; } }
TokenUtils { public static PrivateKey readPrivateKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PrivateKey privateKey = decodePrivateKey(new String(tmp, 0, length)); return privateKey; } private TokenUtils(); }
TokenUtils { public static PrivateKey readPrivateKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PrivateKey privateKey = decodePrivateKey(new String(tmp, 0, length)); return privateKey; } private TokenUtils(); static String generateTokenString(String jsonResName); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static PrivateKey readPrivateKey(String pemResName); static PublicKey readPublicKey(String pemResName); static KeyPair generateKeyPair(int keySize); static PrivateKey decodePrivateKey(String pemEncoded); static PublicKey decodePublicKey(String pemEncoded); }
TokenUtils { public static PrivateKey readPrivateKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PrivateKey privateKey = decodePrivateKey(new String(tmp, 0, length)); return privateKey; } private TokenUtils(); static String generateTokenString(String jsonResName); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static PrivateKey readPrivateKey(String pemResName); static PublicKey readPublicKey(String pemResName); static KeyPair generateKeyPair(int keySize); static PrivateKey decodePrivateKey(String pemEncoded); static PublicKey decodePublicKey(String pemEncoded); }
@Test public void testReadPublicKey() throws Exception { RSAPublicKey publicKey = (RSAPublicKey) TokenUtils.readPublicKey("/publicKey.pem"); System.out.println(publicKey); System.out.printf("RSAPublicKey.bitLength: %s\n", publicKey.getModulus().bitLength()); }
public static PublicKey readPublicKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PublicKey publicKey = decodePublicKey(new String(tmp, 0, length)); return publicKey; }
TokenUtils { public static PublicKey readPublicKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PublicKey publicKey = decodePublicKey(new String(tmp, 0, length)); return publicKey; } }
TokenUtils { public static PublicKey readPublicKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PublicKey publicKey = decodePublicKey(new String(tmp, 0, length)); return publicKey; } private TokenUtils(); }
TokenUtils { public static PublicKey readPublicKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PublicKey publicKey = decodePublicKey(new String(tmp, 0, length)); return publicKey; } private TokenUtils(); static String generateTokenString(String jsonResName); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static PrivateKey readPrivateKey(String pemResName); static PublicKey readPublicKey(String pemResName); static KeyPair generateKeyPair(int keySize); static PrivateKey decodePrivateKey(String pemEncoded); static PublicKey decodePublicKey(String pemEncoded); }
TokenUtils { public static PublicKey readPublicKey(String pemResName) throws Exception { InputStream contentIS = TokenUtils.class.getResourceAsStream(pemResName); byte[] tmp = new byte[4096]; int length = contentIS.read(tmp); PublicKey publicKey = decodePublicKey(new String(tmp, 0, length)); return publicKey; } private TokenUtils(); static String generateTokenString(String jsonResName); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims); static String generateTokenString(String jsonResName, Set<InvalidClaims> invalidClaims, Map<String, Long> timeClaims); static PrivateKey readPrivateKey(String pemResName); static PublicKey readPublicKey(String pemResName); static KeyPair generateKeyPair(int keySize); static PrivateKey decodePrivateKey(String pemEncoded); static PublicKey decodePublicKey(String pemEncoded); }
@Test public void gaugeOnNullValue() { Gauge gauge = registry.gauge("gauge", emptyList(), null, obj -> 1.0); assertEquals(gauge.value(), Double.NaN, 0); }
@Override public <T> Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f) { return new MicrometerGauge<T>(io.micrometer.core.instrument.Gauge.builder(name, obj, f).tags(toTags(tags)).register(registry)); }
MicrometerMetricsRegistry implements MetricsRegistry { @Override public <T> Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f) { return new MicrometerGauge<T>(io.micrometer.core.instrument.Gauge.builder(name, obj, f).tags(toTags(tags)).register(registry)); } }
MicrometerMetricsRegistry implements MetricsRegistry { @Override public <T> Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f) { return new MicrometerGauge<T>(io.micrometer.core.instrument.Gauge.builder(name, obj, f).tags(toTags(tags)).register(registry)); } MicrometerMetricsRegistry(MeterRegistry registry); }
MicrometerMetricsRegistry implements MetricsRegistry { @Override public <T> Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f) { return new MicrometerGauge<T>(io.micrometer.core.instrument.Gauge.builder(name, obj, f).tags(toTags(tags)).register(registry)); } MicrometerMetricsRegistry(MeterRegistry registry); @Override Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f); @Override Counter counter(String name, Collection<Tag> tags); @Override Timer timer(String name, Collection<Tag> tags); }
MicrometerMetricsRegistry implements MetricsRegistry { @Override public <T> Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f) { return new MicrometerGauge<T>(io.micrometer.core.instrument.Gauge.builder(name, obj, f).tags(toTags(tags)).register(registry)); } MicrometerMetricsRegistry(MeterRegistry registry); @Override Gauge gauge(String name, Collection<Tag> tags, T obj, ToDoubleFunction<T> f); @Override Counter counter(String name, Collection<Tag> tags); @Override Timer timer(String name, Collection<Tag> tags); }
@Test public void testFinishAfterFinish() { InMemoryDispatcher dispatcher = new InMemoryDispatcher.Builder(metrics).build(); tracer = new Tracer.Builder(metrics, "remote-dispatcher", dispatcher).build(); Span span = tracer.buildSpan("operation").start(); span.finish(); try { span.finish(); Assert.fail(); } catch (IllegalStateException ex) { } try { dispatcher.flush(); } catch (IOException ex) { Assert.fail(); } Assert.assertEquals(0, dispatcher.getReportedSpans().size()); Assert.assertEquals(1, dispatcher.getFlushedSpans().size()); Assert.assertEquals(1, dispatcher.getReceivedSpans().size()); }
@Override public void finish() { finishTrace(clock.microTime()); }
Span implements io.opentracing.Span { @Override public void finish() { finishTrace(clock.microTime()); } }
Span implements io.opentracing.Span { @Override public void finish() { finishTrace(clock.microTime()); } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); }
Span implements io.opentracing.Span { @Override public void finish() { finishTrace(clock.microTime()); } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override void finish(); @Override void finish(long finishMicros); Long getDuration(); Long getStartTime(); Tracer getTracer(); @Override SpanContext context(); String getServiceName(); String getOperationName(); @Override Span setOperationName(String operationName); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); Map<String, String> getBaggageItems(); @Override Span setTag(String key, Number value); @Override io.opentracing.Span setTag(Tag<T> tag, T value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, String value); Map<String, Object> getTags(); @Override Span log(long timestampMicroseconds, Map<String, ?> fields); @Override Span log(long timestampMicroseconds, String event); @Override Span log(Map<String, ?> fields); @Override Span log(String event); List<LogData> getLogs(); }
Span implements io.opentracing.Span { @Override public void finish() { finishTrace(clock.microTime()); } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override void finish(); @Override void finish(long finishMicros); Long getDuration(); Long getStartTime(); Tracer getTracer(); @Override SpanContext context(); String getServiceName(); String getOperationName(); @Override Span setOperationName(String operationName); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); Map<String, String> getBaggageItems(); @Override Span setTag(String key, Number value); @Override io.opentracing.Span setTag(Tag<T> tag, T value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, String value); Map<String, Object> getTags(); @Override Span log(long timestampMicroseconds, Map<String, ?> fields); @Override Span log(long timestampMicroseconds, String event); @Override Span log(Map<String, ?> fields); @Override Span log(String event); List<LogData> getLogs(); }
@Test public void testDispatch() throws Exception { final Span span = tracer.buildSpan("happy-path").start(); span.finish(); final ArgumentCaptor<com.expedia.open.tracing.Span> spanCapture = ArgumentCaptor.forClass(com.expedia.open.tracing.Span.class); client.send(span); verify(serviceImpl, times(1)).dispatch(spanCapture.capture(), Matchers.<StreamObserver<DispatchResult>>any()); }
@Override public boolean send(Span span) throws ClientException { try (Sample timer = sendTimer.start()) { stub.dispatch(format.format(span), observer); } catch (Exception e) { sendExceptionCounter.increment(); throw new ClientException(e.getMessage(), e); } return true; }
GRPCAgentClient extends BaseGrpcClient<Span> { @Override public boolean send(Span span) throws ClientException { try (Sample timer = sendTimer.start()) { stub.dispatch(format.format(span), observer); } catch (Exception e) { sendExceptionCounter.increment(); throw new ClientException(e.getMessage(), e); } return true; } }
GRPCAgentClient extends BaseGrpcClient<Span> { @Override public boolean send(Span span) throws ClientException { try (Sample timer = sendTimer.start()) { stub.dispatch(format.format(span), observer); } catch (Exception e) { sendExceptionCounter.increment(); throw new ClientException(e.getMessage(), e); } return true; } GRPCAgentClient(Metrics metrics, Format<com.expedia.open.tracing.Span> format, ManagedChannel channel, SpanAgentStub stub, StreamObserver<DispatchResult> observer, long shutdownTimeoutMS); }
GRPCAgentClient extends BaseGrpcClient<Span> { @Override public boolean send(Span span) throws ClientException { try (Sample timer = sendTimer.start()) { stub.dispatch(format.format(span), observer); } catch (Exception e) { sendExceptionCounter.increment(); throw new ClientException(e.getMessage(), e); } return true; } GRPCAgentClient(Metrics metrics, Format<com.expedia.open.tracing.Span> format, ManagedChannel channel, SpanAgentStub stub, StreamObserver<DispatchResult> observer, long shutdownTimeoutMS); @Override boolean send(Span span); }
GRPCAgentClient extends BaseGrpcClient<Span> { @Override public boolean send(Span span) throws ClientException { try (Sample timer = sendTimer.start()) { stub.dispatch(format.format(span), observer); } catch (Exception e) { sendExceptionCounter.increment(); throw new ClientException(e.getMessage(), e); } return true; } GRPCAgentClient(Metrics metrics, Format<com.expedia.open.tracing.Span> format, ManagedChannel channel, SpanAgentStub stub, StreamObserver<DispatchResult> observer, long shutdownTimeoutMS); @Override boolean send(Span span); }
@Test public void testDispatch() throws Exception { final Span span = tracer.buildSpan("happy-path").asChildOf(spanContext).start(); span.finish(); final ArgumentCaptor<HttpPost> httpPostCapture = ArgumentCaptor.forClass(HttpPost.class); final CloseableHttpClient http = Mockito.mock(CloseableHttpClient.class); final CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class); final BasicStatusLine statusLine = new BasicStatusLine(new ProtocolVersion("v", 1, 1), 200, ""); when(http.execute(httpPostCapture.capture())).thenReturn(httpResponse); when(httpResponse.getStatusLine()).thenReturn(statusLine); final Map<String, String> headers = new HashMap<>(); headers.put("client-id", "my-client"); final HttpCollectorClient client = new HttpCollectorClient("http: final boolean isSuccess = client.send(span); client.close(); verify(http, times(1)).execute(httpPostCapture.capture()); verify(httpResponse, times(1)).close(); verify(http, times(1)).close(); verifyCapturedHttpPost(httpPostCapture.getValue()); assertEquals(isSuccess, true); }
@Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); @Override boolean send(Span span); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); @Override boolean send(Span span); }
@Test(expected = ClientException.class) public void testFailedDispatch() throws Exception { final Span span = tracer.buildSpan("sad-path").start(); span.finish(); final ArgumentCaptor<HttpPost> httpPostCapture = ArgumentCaptor.forClass(HttpPost.class); final CloseableHttpClient http = Mockito.mock(CloseableHttpClient.class); final CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class); final BasicStatusLine statusLine = new BasicStatusLine(new ProtocolVersion("v", 1, 1), 404, ""); when(http.execute(httpPostCapture.capture())).thenReturn(httpResponse); when(httpResponse.getStatusLine()).thenReturn(statusLine); final HttpCollectorClient client = new HttpCollectorClient("http: client.send(span); }
@Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); @Override boolean send(Span span); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); @Override boolean send(Span span); }
@Test(expected = ClientException.class) public void testAnotherFailedDispatch() throws Exception { final Span span = tracer.buildSpan("sad-path").start(); span.finish(); final ArgumentCaptor<HttpPost> httpPostCapture = ArgumentCaptor.forClass(HttpPost.class); final CloseableHttpClient http = Mockito.mock(CloseableHttpClient.class); when(http.execute(httpPostCapture.capture())).thenThrow(new IOException()); final HttpCollectorClient client = new HttpCollectorClient("http: client.send(span); }
@Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); @Override boolean send(Span span); }
HttpCollectorClient extends BaseHttpClient implements Client<Span> { @Override public boolean send(Span span) throws ClientException { final byte[] spanBytes = format.format(span).toByteArray(); return super.send(spanBytes); } HttpCollectorClient(String endpoint, Map<String, String> headers); HttpCollectorClient(String endpoint); HttpCollectorClient(final String endpoint, final Map<String, String> headers, final CloseableHttpClient httpClient); @Override boolean send(Span span); }
@Test public void testFlushTimer() { Span span = tracer.buildSpan("happy-path").start(); dispatcher.dispatch(span); Awaitility.await() .atMost(flushInterval * 2, TimeUnit.MILLISECONDS) .until(() -> client.getFlushedSpans().size() > 0); Assert.assertEquals(0, client.getReceivedSpans().size()); Assert.assertEquals(1, client.getFlushedSpans().size()); Assert.assertEquals(1, client.getTotalSpans().size()); }
@Override public void dispatch(Span span) { try (Sample timer = dispatchTimer.start()) { if (running.get()) { final boolean accepted = acceptQueue.offer(span); if (!accepted) { dispatchRejectedCounter.increment(); LOGGER.warn("Send queue is rejecting new spans"); } } else { dispatchRejectedCounter.increment(); LOGGER.warn("Dispatcher is shutting down and queue is now rejecting new spans"); } } }
RemoteDispatcher implements Dispatcher { @Override public void dispatch(Span span) { try (Sample timer = dispatchTimer.start()) { if (running.get()) { final boolean accepted = acceptQueue.offer(span); if (!accepted) { dispatchRejectedCounter.increment(); LOGGER.warn("Send queue is rejecting new spans"); } } else { dispatchRejectedCounter.increment(); LOGGER.warn("Dispatcher is shutting down and queue is now rejecting new spans"); } } } }
RemoteDispatcher implements Dispatcher { @Override public void dispatch(Span span) { try (Sample timer = dispatchTimer.start()) { if (running.get()) { final boolean accepted = acceptQueue.offer(span); if (!accepted) { dispatchRejectedCounter.increment(); LOGGER.warn("Send queue is rejecting new spans"); } } else { dispatchRejectedCounter.increment(); LOGGER.warn("Dispatcher is shutting down and queue is now rejecting new spans"); } } } RemoteDispatcher(Metrics metrics, Client client, BlockingQueue<Span> queue, long flushInterval, long shutdownTimeout, ScheduledExecutorService executor); }
RemoteDispatcher implements Dispatcher { @Override public void dispatch(Span span) { try (Sample timer = dispatchTimer.start()) { if (running.get()) { final boolean accepted = acceptQueue.offer(span); if (!accepted) { dispatchRejectedCounter.increment(); LOGGER.warn("Send queue is rejecting new spans"); } } else { dispatchRejectedCounter.increment(); LOGGER.warn("Dispatcher is shutting down and queue is now rejecting new spans"); } } } RemoteDispatcher(Metrics metrics, Client client, BlockingQueue<Span> queue, long flushInterval, long shutdownTimeout, ScheduledExecutorService executor); @Override String toString(); @Override void dispatch(Span span); @Override void close(); @Override void flush(); }
RemoteDispatcher implements Dispatcher { @Override public void dispatch(Span span) { try (Sample timer = dispatchTimer.start()) { if (running.get()) { final boolean accepted = acceptQueue.offer(span); if (!accepted) { dispatchRejectedCounter.increment(); LOGGER.warn("Send queue is rejecting new spans"); } } else { dispatchRejectedCounter.increment(); LOGGER.warn("Dispatcher is shutting down and queue is now rejecting new spans"); } } } RemoteDispatcher(Metrics metrics, Client client, BlockingQueue<Span> queue, long flushInterval, long shutdownTimeout, ScheduledExecutorService executor); @Override String toString(); @Override void dispatch(Span span); @Override void close(); @Override void flush(); }
@Test public void propagatorInjectsSpanContextIdentitiesAsExpected() { final KeyConvention keyConvention = new DefaultKeyConvention(); final TextMapPropagator propagator = new TextMapPropagator.Builder().withKeyConvention(keyConvention).build(); final MapBackedTextMap carrier = new MapBackedTextMap(); final SpanContext spanContext = new SpanContext(UUID.fromString("8557731e-cce9-45c2-9485-1fd86f5116ca"), UUID.fromString("30898bb0-f836-43fb-ad69-44969f15e52d"), UUID.fromString("3a0bc1c1-504f-4f5d-907b-9b4522453bcf")); propagator.inject(spanContext, carrier); Assert.assertEquals("trace-id was not injected correctly", "8557731e-cce9-45c2-9485-1fd86f5116ca", carrier.get(keyConvention.traceIdKey())); Assert.assertEquals("span-id was not injected correctly", "30898bb0-f836-43fb-ad69-44969f15e52d", carrier.get(keyConvention.spanIdKey())); Assert.assertEquals("parent-id was not injected correctly", "3a0bc1c1-504f-4f5d-907b-9b4522453bcf", carrier.get(keyConvention.parentIdKey())); }
@Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); @Override String toString(); @Override void inject(SpanContext context, TextMap carrier); @Override SpanContext extract(TextMap carrier); }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); @Override String toString(); @Override void inject(SpanContext context, TextMap carrier); @Override SpanContext extract(TextMap carrier); }
@Test public void builderUsesTheProvidedCodexForKeyAndValue() { final KeyConvention keyConvention = new DefaultKeyConvention(); final TextMapCodex codex = new OneAppendingCodex(); final TextMapPropagator propagator = new TextMapPropagator.Builder() .withKeyConvention(keyConvention) .withCodex(codex) .build(); final MapBackedTextMap carrier = new MapBackedTextMap(); final SpanContext spanContext = new SpanContext(UUID.fromString("8557731e-cce9-45c2-9485-1fd86f5116ca"), UUID.fromString("30898bb0-f836-43fb-ad69-44969f15e52d"), UUID.fromString("3a0bc1c1-504f-4f5d-907b-9b4522453bcf")); propagator.inject(spanContext, carrier); Assert.assertEquals("trace-id was not injected correctly", "1-8557731e-cce9-45c2-9485-1fd86f5116ca", carrier.get("1-" + keyConvention.traceIdKey())); Assert.assertEquals("span-id was not injected correctly", "1-30898bb0-f836-43fb-ad69-44969f15e52d", carrier.get("1-" + keyConvention.spanIdKey())); Assert.assertEquals("parent-id was not injected correctly", "1-3a0bc1c1-504f-4f5d-907b-9b4522453bcf", carrier.get("1-" + keyConvention.parentIdKey())); }
@Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); @Override String toString(); @Override void inject(SpanContext context, TextMap carrier); @Override SpanContext extract(TextMap carrier); }
TextMapPropagator implements Injector<TextMap>, Extractor<TextMap> { @Override public void inject(SpanContext context, TextMap carrier) { put(carrier, convention.traceIdKey(), context.getTraceId().toString()); put(carrier, convention.spanIdKey(), context.getSpanId().toString()); if (context.getParentId() != null) { put(carrier, convention.parentIdKey(), context.getParentId().toString()); } for (Map.Entry<String, String> baggage : context.baggageItems()) { put(carrier, prefixKey(convention.baggagePrefix(), baggage.getKey()), baggage.getValue()); } } protected TextMapPropagator(KeyConvention convention, TextMapCodex keyCodex, TextMapCodex valueCodex); @Override String toString(); @Override void inject(SpanContext context, TextMap carrier); @Override SpanContext extract(TextMap carrier); }
@Test public void testServiceName() { String expected = "service-name"; Span span = new Tracer.Builder(metrics, expected, dispatcher).build().buildSpan(expected).start(); Assert.assertEquals(expected, span.getServiceName()); }
public String getServiceName() { synchronized (this) { return getTracer().getServiceName(); } }
Span implements io.opentracing.Span { public String getServiceName() { synchronized (this) { return getTracer().getServiceName(); } } }
Span implements io.opentracing.Span { public String getServiceName() { synchronized (this) { return getTracer().getServiceName(); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); }
Span implements io.opentracing.Span { public String getServiceName() { synchronized (this) { return getTracer().getServiceName(); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override void finish(); @Override void finish(long finishMicros); Long getDuration(); Long getStartTime(); Tracer getTracer(); @Override SpanContext context(); String getServiceName(); String getOperationName(); @Override Span setOperationName(String operationName); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); Map<String, String> getBaggageItems(); @Override Span setTag(String key, Number value); @Override io.opentracing.Span setTag(Tag<T> tag, T value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, String value); Map<String, Object> getTags(); @Override Span log(long timestampMicroseconds, Map<String, ?> fields); @Override Span log(long timestampMicroseconds, String event); @Override Span log(Map<String, ?> fields); @Override Span log(String event); List<LogData> getLogs(); }
Span implements io.opentracing.Span { public String getServiceName() { synchronized (this) { return getTracer().getServiceName(); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override void finish(); @Override void finish(long finishMicros); Long getDuration(); Long getStartTime(); Tracer getTracer(); @Override SpanContext context(); String getServiceName(); String getOperationName(); @Override Span setOperationName(String operationName); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); Map<String, String> getBaggageItems(); @Override Span setTag(String key, Number value); @Override io.opentracing.Span setTag(Tag<T> tag, T value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, String value); Map<String, Object> getTags(); @Override Span log(long timestampMicroseconds, Map<String, ?> fields); @Override Span log(long timestampMicroseconds, String event); @Override Span log(Map<String, ?> fields); @Override Span log(String event); List<LogData> getLogs(); }
@Test public void testTagForTagType() { String key = "typed-key-name"; String value = "typed-tag-value-value"; StringTag stringTag = new StringTag(key); stringTag.set(span, value); Assert.assertEquals(value, span.getTags().get(key)); }
public Map<String, Object> getTags() { synchronized (this) { return Collections.unmodifiableMap(tags); } }
Span implements io.opentracing.Span { public Map<String, Object> getTags() { synchronized (this) { return Collections.unmodifiableMap(tags); } } }
Span implements io.opentracing.Span { public Map<String, Object> getTags() { synchronized (this) { return Collections.unmodifiableMap(tags); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); }
Span implements io.opentracing.Span { public Map<String, Object> getTags() { synchronized (this) { return Collections.unmodifiableMap(tags); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override void finish(); @Override void finish(long finishMicros); Long getDuration(); Long getStartTime(); Tracer getTracer(); @Override SpanContext context(); String getServiceName(); String getOperationName(); @Override Span setOperationName(String operationName); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); Map<String, String> getBaggageItems(); @Override Span setTag(String key, Number value); @Override io.opentracing.Span setTag(Tag<T> tag, T value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, String value); Map<String, Object> getTags(); @Override Span log(long timestampMicroseconds, Map<String, ?> fields); @Override Span log(long timestampMicroseconds, String event); @Override Span log(Map<String, ?> fields); @Override Span log(String event); List<LogData> getLogs(); }
Span implements io.opentracing.Span { public Map<String, Object> getTags() { synchronized (this) { return Collections.unmodifiableMap(tags); } } Span(Tracer tracer, Clock clock, String operationName, SpanContext context, long startTime, Map<String, Object> tags, List<Reference> references); @Override String toString(); @Override void finish(); @Override void finish(long finishMicros); Long getDuration(); Long getStartTime(); Tracer getTracer(); @Override SpanContext context(); String getServiceName(); String getOperationName(); @Override Span setOperationName(String operationName); @Override Span setBaggageItem(String key, String value); @Override String getBaggageItem(String key); Map<String, String> getBaggageItems(); @Override Span setTag(String key, Number value); @Override io.opentracing.Span setTag(Tag<T> tag, T value); @Override Span setTag(String key, boolean value); @Override Span setTag(String key, String value); Map<String, Object> getTags(); @Override Span log(long timestampMicroseconds, Map<String, ?> fields); @Override Span log(long timestampMicroseconds, String event); @Override Span log(Map<String, ?> fields); @Override Span log(String event); List<LogData> getLogs(); }
@Test public void testExecuteJobErrCndtn() { EventJobDTO eventDTO = createEventJobDTO(); eventDTO.getEventMonkeyList().get(0).setMonkeyScriptType(""); EventJobDTO returnDTO = (EventJobDTO) eventJobController.executeJob(eventDTO).getBody(); System.out.println("return "); assertEquals("Monkey Script Type is blank for Monkey Strategy : "+ eventDTO.getEventMonkeyList().get(0).getMonkeyStrategy() +" . So Scenario Execution is terminated.", returnDTO.getEventMonkeyList().get(0).getExecStatus()); assertEquals("000", returnDTO.getEventMonkeyList().get(0).getReturnCode()); eventDTO = createEventJobDTO(); eventDTO.getEventMonkeyList().get(0).setMonkeyScriptContent(""); returnDTO = (EventJobDTO) eventJobController.executeJob(eventDTO).getBody(); assertEquals("Monkey Script Content is empty for Monkey Strategy : "+ eventDTO.getEventMonkeyList().get(0).getMonkeyStrategy() +" . So Scenario Execution is terminated.", returnDTO.getEventMonkeyList().get(0).getExecStatus()); assertEquals("000", returnDTO.getEventMonkeyList().get(0).getReturnCode()); }
@ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO); @ApiOperation(value = "This API streams real time Event Job status for given Event ID", response = ResponseBodyEmitter.class) @RequestMapping(value = "/eventStatus/{eventId}", method = RequestMethod.GET) ResponseBodyEmitter getEventStream(@PathVariable("eventId") String eventId); }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO); @ApiOperation(value = "This API streams real time Event Job status for given Event ID", response = ResponseBodyEmitter.class) @RequestMapping(value = "/eventStatus/{eventId}", method = RequestMethod.GET) ResponseBodyEmitter getEventStream(@PathVariable("eventId") String eventId); static final Logger logger; }
@Test public void testDeleteAllScenarios() { ResponseEntity<Object> response = scenarioController.deleteAllScenarios(); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(scenarioRepository, times(1)).deleteAll(); }
@ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllScenarios() { logger.debug("Deleting All Scenarios"); scenarioService.deleteAllScenarios(); return new ResponseEntity<>(HttpStatus.OK); }
ScenarioRestController { @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllScenarios() { logger.debug("Deleting All Scenarios"); scenarioService.deleteAllScenarios(); return new ResponseEntity<>(HttpStatus.OK); } }
ScenarioRestController { @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllScenarios() { logger.debug("Deleting All Scenarios"); scenarioService.deleteAllScenarios(); return new ResponseEntity<>(HttpStatus.OK); } }
ScenarioRestController { @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllScenarios() { logger.debug("Deleting All Scenarios"); scenarioService.deleteAllScenarios(); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request, @RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request, @RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); }
ScenarioRestController { @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> deleteAllScenarios() { logger.debug("Deleting All Scenarios"); scenarioService.deleteAllScenarios(); return new ResponseEntity<>(HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request, @RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request, @RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); }
@Test public void testBulkDeleteScenarioErrCndtn() { List<Scenario> sceList = new ArrayList<>(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); scenario.setId(""); sceList.add(scenario); ScenarioAdapter sceAdapter = new ScenarioAdapter(); sceAdapter.setScenarios(sceList); MessageWrapper apiError = (MessageWrapper) scenarioController.bulkdeleteScenario(sceAdapter).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("Scenario Id cannot be empty.", apiError.getStatusMessage()); }
@ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request, @RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request, @RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request, @RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request, @RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); }
@Test public void testBulkDeleteScenario() { List<Scenario> sceList = new ArrayList<>(); Scenario scenario = createScenario(SCENARIONAME, TEAMNAME); sceList.add(scenario); ScenarioAdapter sceAdapter = new ScenarioAdapter(); sceAdapter.setScenarios(sceList); ResponseEntity<Object> response = scenarioController.bulkdeleteScenario(sceAdapter); assertEquals(HttpStatus.OK, response.getStatusCode()); verify(scenarioRepository, times(1)).delete(scenario); }
@ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request, @RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request, @RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); }
ScenarioRestController { @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") public ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter) { logger.debug("Bulk inserting scenarios Total #-->" + scenarioAdapter.getScenarios().size()); for (Scenario scenario : scenarioAdapter.getScenarios()) { if (scenario.getId() == null || "".trim().equals(scenario.getId())) { final String error = "Scenario Id cannot be empty."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } scenarioService.delete(scenario); } HttpHeaders headers = new HttpHeaders(); return new ResponseEntity<>(headers, HttpStatus.OK); } @ApiOperation(value = "This API returns all Scenario Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.GET) ResponseEntity<List<Scenario>> listScenarios(); @ApiOperation(value = "This API returns list of all Scenario objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Scenario Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given team") }) @RequestMapping(value = "/api/scenarios/team/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<List<Scenario>> listAllScenarios(HttpServletRequest request); @ApiOperation(value = "This API returns count of Scenario objects available in Elastic Search for team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Scenario objects for team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/scenarios/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario ID") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenario(@PathVariable("id") String id); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Scenario Objects for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given App Name") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName:.+}", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllScenariosByApplicationName(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API returns single Scenario Object present in Elastic Search for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name") }) @RequestMapping(value = "/api/scenarios/scenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns Scenario Objects present in Elastic Search for given Scenario Name and team Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Scenario Object for given Scenario Name and team Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Scenario object found for given Scenario Name and team Name") }) @RequestMapping(value = "/api/scenarios/listscenariobyname/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getScenarioListByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API inserts a Scenario Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenario/", method = RequestMethod.POST, produces = "application/json", consumes = MediaType.ALL_VALUE) ResponseEntity<Object> addScenario(HttpServletRequest request, @RequestBody Scenario scenario, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario objects successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateScenario(HttpServletRequest request, @PathVariable("id") String id, @RequestBody Scenario toModifyScenario); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given Scenario ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given Scenario ID"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given Scenario ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenario(@PathVariable("id") String id); @ApiOperation(value = "This API deletes a Scenario Objects from Elastic Search for given App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES for given App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "Scenario object not found in ES for given App Name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/scenariosby-appname/{applicationName}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteScenarioForApplication(HttpServletRequest request, @PathVariable("applicationName") String applicationName); @ApiOperation(value = "This API deletes all Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "All Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deleteAllScenarios(); @ApiOperation(value = "This API do bulk insertion of Scenario Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Scenario objects successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Scenario with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> bulkaddScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API deletes Bulk Scenario Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/scenarios/bulk/", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> bulkdeleteScenario(@RequestBody ScenarioAdapter scenarioAdapter); @ApiOperation(value = "This API executes a Scenario for given Scenario Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/{name:.+}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> executeScenariobyScenarioName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API executes a Scenario for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenario(HttpServletRequest request, @RequestBody final Scenario execScenario1); @ApiOperation(value = "This API executes a Scenario for given Name and App Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario successfully executed for given Name and App Name"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executescenariowithapplication/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeScenarioWithApplication(HttpServletRequest request, @RequestBody final ScenarioExecutionAdapter scenarioAdapter); @ApiOperation(value = "This API do bulk execution of Scenarios", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Bulk Scenario execution is completed successfully"), @ApiResponse(code = 401, message = "User is not authorized to perform execute a Scenario"), @ApiResponse(code = 404, message = "Scenario not found for given name"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/executebulkscenario/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeBulkScenario(HttpServletRequest request, @RequestBody ScenarioAdapter scenarioAdapter); }
@Test public void testGetMonkeyStrategyByNameErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyStrategyNameAndTeamName(MONKEYSTRATEGYNAME, TEAMNAME)) .thenReturn(null); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .getMonkeyStrategyByName(req, MONKEYSTRATEGYNAME).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Monkey Strategy not found for Team : " + MONKEYSTRATEGYNAME + ", " + TEAMNAME, apiError.getStatusMessage()); }
@ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name) { logger.debug("Fetching monkeyStrategy with name : %s", name); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamName(name, teamName); if (monkeyStrategy == null) { final String error = "Monkey Strategy not found for Team : " + name + ", " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testGetDefaultMonkeyStrategy() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkeyStrategy); Page<MonkeyStrategy> monkeyStrategyPage = new PageImpl<>(monkeyStrategies); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyTypeAndMonkeyStrategyNameAndDefaultFlagAndTeamName( monkeyStrategy.getMonkeyType().monkeyType(), MONKEYSTRATEGYNAME, "Y", TEAMNAME)) .thenReturn(monkeyStrategyPage); MonkeyStrategy getMonkeyStrategy = (MonkeyStrategy) monkeyStrategyController.getDefaultMonkeyStrategy(req, monkeyStrategy.getMonkeyStrategyName(), monkeyStrategy.getMonkeyType().monkeyType()).getBody(); assertEquals(MONKEYSTRATEGYNAME, getMonkeyStrategy.getMonkeyStrategyName()); assertEquals(TEAMNAME, getMonkeyStrategy.getTeamName()); }
@ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testGetDefaultMonkeyStrategyErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyTypeAndMonkeyStrategyNameAndDefaultFlagAndTeamName( monkeyStrategy.getMonkeyType().monkeyType(), MONKEYSTRATEGYNAME, "Y", TEAMNAME)).thenReturn(null); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .getDefaultMonkeyStrategy(req, MONKEYSTRATEGYNAME, monkeyStrategy.getMonkeyType().monkeyType()) .getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("Default Monkey Strategy not found with name & monkeyType : " + MONKEYSTRATEGYNAME + " ," + monkeyStrategy.getMonkeyType() + " for Team " + TEAMNAME, apiError.getStatusMessage()); }
@ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyType monkeyType = MonkeyType.fromString(monkeyTypeStr.trim()); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findDefaultMonkeyStrategy(name, monkeyType, teamName); if (monkeyStrategy == null) { final String error = "Default Monkey Strategy not found with name & monkeyType : " + name + " ," + monkeyType + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testGetMonkeyStrategyByNameAndVersion() { setSecuirtyContext(TEAMNAME, USERNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyStrategyNameAndTeamNameAndMonkeyStrategyVersion(MONKEYSTRATEGYNAME, TEAMNAME, monkeyStrategy.getMonkeyStrategyVersion())).thenReturn(monkeyStrategy); MonkeyStrategy getMonkeyStrategy = (MonkeyStrategy) monkeyStrategyController.getMonkeyStrategyByNameAndVersion( req, monkeyStrategy.getMonkeyStrategyName(), monkeyStrategy.getMonkeyStrategyVersion()).getBody(); assertEquals(MONKEYSTRATEGYNAME, getMonkeyStrategy.getMonkeyStrategyName()); assertEquals(TEAMNAME, getMonkeyStrategy.getTeamName()); }
@ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testGetMonkeyStrategyByNameAndVersionErrCndtn() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyStrategyNameAndTeamNameAndMonkeyStrategyVersion(MONKEYSTRATEGYNAME, TEAMNAME, monkeyStrategy.getMonkeyStrategyVersion())).thenReturn(null); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .getMonkeyStrategyByNameAndVersion(req, MONKEYSTRATEGYNAME, monkeyStrategy.getMonkeyStrategyVersion()) .getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("monkeyStrategy " + MONKEYSTRATEGYNAME + " and verion " + monkeyStrategy.getMonkeyStrategyVersion() + " not found " + " for Team " + TEAMNAME, apiError.getStatusMessage()); }
@ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version) { logger.debug("Fetching monkeyStrategy : %s and version: %s", name, version); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy monkeyStrategy = monkeyStrategyService.findByMonkeyStrategyNameAndTeamNameAndVersion(name, teamName, version); if (monkeyStrategy == null) { final String error = "monkeyStrategy " + name + " and verion " + version + " not found " + " for Team " + teamName; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } return new ResponseEntity<>(monkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testCountByTeamName() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); when(monkeyStrategyRepository.countByTeamName(TEAMNAME)).thenReturn((long) 1); when(monkeyStrategyRepository.count()).thenReturn((long) 2); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); String appCount = (String) monkeyStrategyController.countByTeamName(req).getBody(); assertEquals("1", appCount); teamUser.setTeamName(ALPHATEAMNAME); setSecuirtyContext(ALPHATEAMNAME, USERNAME); appCount = (String) monkeyStrategyController.countByTeamName(req).getBody(); assertEquals("2", appCount); }
@ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = monkeyStrategyService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = monkeyStrategyService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = monkeyStrategyService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = monkeyStrategyService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") public ResponseEntity<Object> countByTeamName(HttpServletRequest request) { final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); Long count = monkeyStrategyService.countByTeamName(teamName); return new ResponseEntity<>(count.toString(), HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testAddMonkeyStrategyErrCndtn() { MonkeyStrategy monkeyStrategy = null; UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .addMonkeyStrategy(req, monkeyStrategy, ucBuilder).getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("NULL request received to add monkeyStrategy", apiError.getStatusMessage()); monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); monkeyStrategy.setMonkeyStrategyName(""); apiError = (MessageWrapper) monkeyStrategyController.addMonkeyStrategy(req, monkeyStrategy, ucBuilder) .getBody(); assertEquals(HttpStatus.BAD_REQUEST, apiError.getStatus()); assertEquals("Monkey Strategy name is empty", apiError.getStatusMessage()); setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); monkeyStrategy.setDefaultFlag("Y"); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkeyStrategy); Page<MonkeyStrategy> monkeyStrategyPage = new PageImpl<>(monkeyStrategies); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyTypeAndMonkeyStrategyNameAndDefaultFlagAndTeamName( monkeyStrategy.getMonkeyType().monkeyType(), MONKEYSTRATEGYNAME, monkeyStrategy.getDefaultFlag(), TEAMNAME)).thenReturn(monkeyStrategyPage); apiError = (MessageWrapper) monkeyStrategyController.addMonkeyStrategy(req, monkeyStrategy, ucBuilder) .getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist", apiError.getStatusMessage()); }
@ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testAddMonkeyStrategy() { UriComponentsBuilder ucBuilder = UriComponentsBuilder.newInstance(); setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); monkeyStrategy.setDefaultFlag("N"); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkeyStrategy); Page<MonkeyStrategy> monkeyStrategyPage = new PageImpl<>(monkeyStrategies); List<MonkeyStrategy> smonkeyStrategies = new ArrayList<>(); Page<MonkeyStrategy> smonkeyStrategyPage = new PageImpl<>(smonkeyStrategies); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findByMonkeyTypeAndMonkeyStrategyNameAndDefaultFlagAndTeamName( monkeyStrategy.getMonkeyType().monkeyType(), MONKEYSTRATEGYNAME, "Y", TEAMNAME)) .thenReturn(monkeyStrategyPage); when(monkeyStrategyRepository.findByMonkeyTypeAndMonkeyStrategyNameAndTeamName( monkeyStrategy.getMonkeyType().monkeyType(), monkeyStrategy.getMonkeyStrategyName(), TEAMNAME)) .thenReturn(smonkeyStrategyPage); when(monkeyStrategyRepository.save(monkeyStrategy)).thenReturn(monkeyStrategy); ResponseEntity<Object> response = monkeyStrategyController.addMonkeyStrategy(req, monkeyStrategy, ucBuilder); assertEquals(HttpStatus.CREATED, response.getStatusCode()); }
@ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder) { if (monkeyStrategy == null) { final String error = "NULL request received to add monkeyStrategy"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (monkeyStrategy.getMonkeyStrategyName() == null || "".equals(monkeyStrategy.getMonkeyStrategyName().trim())) { final String error = "Monkey Strategy name is empty"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.BAD_REQUEST, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); monkeyStrategy.setTeamName(teamName); logger.debug("Creating monkeyStrategy with name -->" + monkeyStrategy.getMonkeyStrategyName()); if (insertMonkeyStrategy(monkeyStrategy, teamName)) { final String error = "MonkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } logger.debug("MonkeyStrategy saved in ES with id -->" + monkeyStrategy.getId()); HttpHeaders headers = new HttpHeaders(); headers.setLocation(ucBuilder.path("/monkeyStrategy/{id}").buildAndExpand(monkeyStrategy.getId()).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testUpdateMonkeyStrategyErrCndtn() { MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); setSecuirtyContext(OTHERTEAM, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, OTHERTEAM); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); MessageWrapper apiError = (MessageWrapper) monkeyStrategyController .updateMonkeyStrategy(req, monkeyStrategy.getId(), monkeyStrategy).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("MonkeyStrategy can be changed only by the owning Team:" + monkeyStrategy.getTeamName(), apiError.getStatusMessage()); teamUser.setTeamName(TEAMNAME); setSecuirtyContext(TEAMNAME, USERNAME); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); apiError = (MessageWrapper) monkeyStrategyController .updateMonkeyStrategy(req, monkeyStrategy.getId(), monkeyStrategy).getBody(); assertEquals(HttpStatus.NOT_FOUND, apiError.getStatus()); assertEquals("MonkeyStrategy with id " + monkeyStrategy.getId() + " not found", apiError.getStatusMessage()); monkeyStrategy.setDefaultFlag("Y"); MonkeyStrategy secondMonkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); secondMonkeyStrategy.setDefaultFlag("Y"); secondMonkeyStrategy.setId("secondMonkeyStrategyID"); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(secondMonkeyStrategy); Page<MonkeyStrategy> monkeyStrategyPage = new PageImpl<>(monkeyStrategies); when(monkeyStrategyRepository.findOne(monkeyStrategy.getId())).thenReturn(monkeyStrategy); when(monkeyStrategyRepository.findByMonkeyTypeAndMonkeyStrategyNameAndDefaultFlagAndTeamName( monkeyStrategy.getMonkeyType().monkeyType(), MONKEYSTRATEGYNAME, "Y", TEAMNAME)) .thenReturn(monkeyStrategyPage); apiError = (MessageWrapper) monkeyStrategyController .updateMonkeyStrategy(req, monkeyStrategy.getId(), monkeyStrategy).getBody(); assertEquals(HttpStatus.CONFLICT, apiError.getStatus()); assertEquals("Default monkeyStrategy with name " + monkeyStrategy.getMonkeyStrategyName() + " already exist.", apiError.getStatusMessage()); }
@ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testUpdateMonkeyStrategy() { setSecuirtyContext(TEAMNAME, USERNAME); TeamUser teamUser = createTeamUserObject(USERNAME, TEAMNAME); MonkeyStrategy monkeyStrategy = createMonkeyStrategy(MONKEYSTRATEGYNAME, TEAMNAME); List<MonkeyStrategy> monkeyStrategies = new ArrayList<>(); monkeyStrategies.add(monkeyStrategy); Page<MonkeyStrategy> monkeyStrategyPage = new PageImpl<>(monkeyStrategies); when(teamUserRepository.findByUserNameAndDefaultFlag(USERNAME, "Y")).thenReturn(teamUser); when(monkeyStrategyRepository.findOne(monkeyStrategy.getId())).thenReturn(monkeyStrategy); when(monkeyStrategyRepository.save(monkeyStrategy)).thenReturn(monkeyStrategy); when(monkeyStrategyRepository.findByMonkeyTypeAndMonkeyStrategyNameAndDefaultFlagAndTeamName( monkeyStrategy.getMonkeyType().monkeyType(), MONKEYSTRATEGYNAME, "Y", TEAMNAME)) .thenReturn(monkeyStrategyPage); ResponseEntity<Object> response = monkeyStrategyController.updateMonkeyStrategy(req, monkeyStrategy.getId(), monkeyStrategy); MonkeyStrategy getMS = (MonkeyStrategy) response.getBody(); assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(TEAMNAME, getMS.getTeamName()); assertEquals(MONKEYSTRATEGYNAME, getMS.getMonkeyStrategyName()); }
@ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
MonkeyStrategyRestController { @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") public ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy) { logger.debug("Updating monkeyStrategy : %s", id); final String teamName = userDetailsService.getCurrentTeamForUser(request).getTeamName(); MonkeyStrategy currentMonkeyStrategy = monkeyStrategyService.findOneForTeam(id, teamName); if (!AppUtil.getSuperUser().equalsIgnoreCase(toModifyMonkeyStrategy.getTeamName()) && !toModifyMonkeyStrategy.getTeamName().equalsIgnoreCase(teamName)) { final String error = "MonkeyStrategy can be changed only by the owning Team:" + toModifyMonkeyStrategy.getTeamName(); logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (currentMonkeyStrategy == null) { final String error = "MonkeyStrategy with id " + id + " not found"; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.NOT_FOUND, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } if (isDefaultStrategyExist(toModifyMonkeyStrategy, teamName)) { final String error = "Default monkeyStrategy with name " + toModifyMonkeyStrategy.getMonkeyStrategyName() + " already exist."; logger.debug(error); final MessageWrapper apiError = new MessageWrapper(HttpStatus.CONFLICT, error, error); return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus()); } toModifyMonkeyStrategy.setId(id); toModifyMonkeyStrategy.setTeamName(teamName); monkeyStrategyService.update(toModifyMonkeyStrategy); return new ResponseEntity<>(toModifyMonkeyStrategy, HttpStatus.OK); } @ApiOperation(value = "This API returns all Monkey Strategy Objects present in Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found") }) @RequestMapping(value = "/api/monkeystrategies/", method = RequestMethod.GET) ResponseEntity<Object> listAllMonkeyStrategies(); @ApiOperation(value = "This API returns list of all Monkey Strategy objects present in Elastic Search for given team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned all Monkey Strategy Objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given team") }) @RequestMapping(value = "/api/monkeystrategies/team-strategies/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyStrategy(HttpServletRequest request); @ApiOperation(value = "This API returns List of Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Type values"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeytypes/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> listAllMonkeyTypes(); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy ID", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned single Monkey Strategy Object for given Monkey Strategy ID"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy ID") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id); @ApiOperation(value = "This API returns single Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name") }) @RequestMapping(value = "/api/monkeystrategies/monkeystrategybyname/{name}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByName(HttpServletRequest request, @PathVariable("name") String name); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Monkey Type", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Monkey Type"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Monkey Type") }) @RequestMapping(value = "/api/monkeystrategies/defaultmonkeystrategy/{name}/{monkeytype}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getDefaultMonkeyStrategy(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("monkeytype") String monkeyTypeStr); @ApiOperation(value = "This API returns single Default Monkey Strategy Object present in Elastic Search for given Monkey Strategy Name & Version", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given Monkey Strategy Name & Version"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given Monkey Strategy Name & Version") }) @RequestMapping(value = "/api/monkeystrategies/{name}/{version}/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getMonkeyStrategyByNameAndVersion(HttpServletRequest request, @PathVariable("name") String name, @PathVariable("version") String version); @ApiOperation(value = "This API returns count of Monkey Strategy objects available in Elastic Search for a team", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned count of Monkey Strategy objects for given team"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/api/monkeystrategies/count/", method = RequestMethod.GET, produces = "application/json") ResponseEntity<Object> countByTeamName(HttpServletRequest request); @ApiOperation(value = "This API returns Monkey Strategy Objects present in Elastic Search for given App Emvironment and team name", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Returned Monkey Strategy Object for given App Emvironment and team name"), @ApiResponse(code = 401, message = "User is not authorized to view requested object"), @ApiResponse(code = 404, message = "No Monkey Strategy object found for given App Emvironment and team name") }) @RequestMapping(value = "/api/monkeystrategies/autodiscover/{applicationname}/{environmentname}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ResponseEntity<Object> getFailurePointByApplicationEnvironmentAndTeamName(HttpServletRequest request, @PathVariable("applicationname") String applicationname, @PathVariable("environmentname") String environmentname); @ApiOperation(value = "This API inserts a Monkey Strategy Object into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Monkey Strategy object successfully inserted into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Add operation"), @ApiResponse(code = 409, message = "Monkey Strategy with same name is already exist"), @ApiResponse(code = 404, message = "The resource trying to reach is not found"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategy/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> addMonkeyStrategy(HttpServletRequest request, @RequestBody MonkeyStrategy monkeyStrategy, UriComponentsBuilder ucBuilder); @ApiOperation(value = "This API updates a Monkey Strategy Objects into Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully updated into ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Update operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be changed only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.PUT, produces = "application/json") ResponseEntity<Object> updateMonkeyStrategy(HttpServletRequest request, @PathVariable("id") String id, @RequestBody MonkeyStrategy toModifyMonkeyStrategy); @ApiOperation(value = "This API deletes a Monkey Strategy Objects from Elastic Search", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Monkey Strategy object successfully deleted from ES"), @ApiResponse(code = 401, message = "User is not authorized to perform Delete operation"), @ApiResponse(code = 409, message = "Monkey Strategy can be delted only by the owning team"), @ApiResponse(code = 404, message = "Monkey Strategy object not found in ES for given Monkey Strategy ID"), @ApiResponse(code = 400, message = "Input Request object is not valid") }) @RequestMapping(value = "/api/monkeystrategies/{id}", method = RequestMethod.DELETE, produces = "application/json") ResponseEntity<Object> deletemonkeystrategy(HttpServletRequest request, @PathVariable("id") String id); }
@Test public void testExecuteJob() { EventJobDTO eventDTO = createEventJobDTO(); ConcurrentMap<String, String> eventData = new ConcurrentHashMap<>(); eventData.put(eventDTO.getEventId(), startString); eventDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); EventJobDTO returnDTO = (EventJobDTO) eventJobController.executeJob(eventDTO).getBody(); verify(eventService, times(1)).executeJob(eventDTO, eventData); assertEquals(startString, returnDTO.getExecStatus()); }
@ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO); @ApiOperation(value = "This API streams real time Event Job status for given Event ID", response = ResponseBodyEmitter.class) @RequestMapping(value = "/eventStatus/{eventId}", method = RequestMethod.GET) ResponseBodyEmitter getEventStream(@PathVariable("eventId") String eventId); }
EventJobExecutionController { @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") public ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO) { StringBuilder errorMsg = new StringBuilder(); if (validateEventJobDTO(eventJobDTO, errorMsg)) { logger.error(errorMsg.toString()); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { eventMonkeyDTO.setReturnCode("000"); eventMonkeyDTO.setExecStatus(errorMsg.toString()); }); eventData.put(eventJobDTO.getEventId(), errorMsg + completeString); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } eventJobDTO.setExecStatus(startString); eventData.put(eventJobDTO.getEventId(), startString); eventJobDTO.getEventMonkeyList().forEach( eventMonkeyDTO -> eventMonkeyDTO.setExecStatus(startString + eventMonkeyDTO.getMonkeyStrategy())); eventJobService.executeJob(eventJobDTO, eventData); eventJobDTO.getEventMonkeyList().forEach(eventMonkeyDTO -> { if (eventMonkeyDTO.getExecStatus() != null) { int maxLength = (eventMonkeyDTO.getExecStatus().length() < 32765) ? eventMonkeyDTO.getExecStatus().length() : 32765; eventMonkeyDTO.setExecStatus(eventMonkeyDTO.getExecStatus().substring(0, maxLength)); } }); return new ResponseEntity<>(eventJobDTO, HttpStatus.OK); } @ApiOperation(value = "This API executes a Monkey Scripts for given Scenario Object", response = ResponseEntity.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "Scenario is executed Successfully"), @ApiResponse(code = 404, message = "The resource trying to reach is not found") }) @RequestMapping(value = "/execJob/", method = RequestMethod.POST, produces = "application/json") ResponseEntity<Object> executeJob(@RequestBody EventJobDTO eventJobDTO); @ApiOperation(value = "This API streams real time Event Job status for given Event ID", response = ResponseBodyEmitter.class) @RequestMapping(value = "/eventStatus/{eventId}", method = RequestMethod.GET) ResponseBodyEmitter getEventStream(@PathVariable("eventId") String eventId); static final Logger logger; }