repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
fjorum/fjorum
src/main/java/org/fjorum/model/service/ReplyServiceImpl.java
// Path: src/main/java/org/fjorum/controller/form/ReplyCreateForm.java // public class ReplyCreateForm { // // public final static String NAME = "replyCreateForm"; // // @NotNull // private User user; // // @NotNull // private Topic topic; // // @NotEmpty // private String content = ""; // // ReplyCreateForm(){} // // public ReplyCreateForm(User user, Topic topic) { // this.user = user; // this.topic = topic; // } // // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // public Topic getTopic() { // return topic; // } // // public void setTopic(Topic topic) { // this.topic = topic; // } // // public String getContent() { // return content; // } // // public void setContent(String content) { // this.content = content; // } // }
import org.fjorum.controller.form.ReplyCreateForm; import org.fjorum.model.entity.Reply; import org.fjorum.model.entity.Topic; import org.fjorum.model.entity.User; import org.fjorum.model.repository.ReplyRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.util.Objects;
package org.fjorum.model.service; @Service public class ReplyServiceImpl extends AbstractEntityServiceImpl<Reply> implements ReplyService { private final ReplyRepository replyRepository; private final TopicService topicService; @Autowired public ReplyServiceImpl(ReplyRepository replyRepository, TopicService topicService) { this.replyRepository = replyRepository; this.topicService = topicService; } @Override
// Path: src/main/java/org/fjorum/controller/form/ReplyCreateForm.java // public class ReplyCreateForm { // // public final static String NAME = "replyCreateForm"; // // @NotNull // private User user; // // @NotNull // private Topic topic; // // @NotEmpty // private String content = ""; // // ReplyCreateForm(){} // // public ReplyCreateForm(User user, Topic topic) { // this.user = user; // this.topic = topic; // } // // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // public Topic getTopic() { // return topic; // } // // public void setTopic(Topic topic) { // this.topic = topic; // } // // public String getContent() { // return content; // } // // public void setContent(String content) { // this.content = content; // } // } // Path: src/main/java/org/fjorum/model/service/ReplyServiceImpl.java import org.fjorum.controller.form.ReplyCreateForm; import org.fjorum.model.entity.Reply; import org.fjorum.model.entity.Topic; import org.fjorum.model.entity.User; import org.fjorum.model.repository.ReplyRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.util.Objects; package org.fjorum.model.service; @Service public class ReplyServiceImpl extends AbstractEntityServiceImpl<Reply> implements ReplyService { private final ReplyRepository replyRepository; private final TopicService topicService; @Autowired public ReplyServiceImpl(ReplyRepository replyRepository, TopicService topicService) { this.replyRepository = replyRepository; this.topicService = topicService; } @Override
public Reply createNewReply(ReplyCreateForm form) {
fjorum/fjorum
src/main/java/org/fjorum/model/service/TopicServiceImpl.java
// Path: src/main/java/org/fjorum/controller/form/TopicCreateForm.java // public class TopicCreateForm { // // public static final String NAME = "topicCreateForm"; // // @NotEmpty // private String topicName = ""; // // @NotNull // private User user; // // @NotNull // private Category category; // // TopicCreateForm() { // } // // public TopicCreateForm(User user, Category category) { // this.user = user; // this.category = category; // } // // public Category getCategory() { // return category; // } // // public void setCategory(Category category) { // this.category = category; // } // // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // public String getTopicName() { // return topicName; // } // // public void setTopicName(String topicName) { // this.topicName = topicName; // } // // }
import org.fjorum.controller.form.TopicCreateForm; import org.fjorum.model.entity.Category; import org.fjorum.model.entity.Topic; import org.fjorum.model.entity.User; import org.fjorum.model.repository.TopicRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service;
package org.fjorum.model.service; @Service public class TopicServiceImpl extends AbstractEntityServiceImpl<Topic> implements TopicService { private final TopicRepository topicRepository; @Autowired public TopicServiceImpl(TopicRepository topicRepository) { this.topicRepository = topicRepository; } @Override
// Path: src/main/java/org/fjorum/controller/form/TopicCreateForm.java // public class TopicCreateForm { // // public static final String NAME = "topicCreateForm"; // // @NotEmpty // private String topicName = ""; // // @NotNull // private User user; // // @NotNull // private Category category; // // TopicCreateForm() { // } // // public TopicCreateForm(User user, Category category) { // this.user = user; // this.category = category; // } // // public Category getCategory() { // return category; // } // // public void setCategory(Category category) { // this.category = category; // } // // public User getUser() { // return user; // } // // public void setUser(User user) { // this.user = user; // } // // public String getTopicName() { // return topicName; // } // // public void setTopicName(String topicName) { // this.topicName = topicName; // } // // } // Path: src/main/java/org/fjorum/model/service/TopicServiceImpl.java import org.fjorum.controller.form.TopicCreateForm; import org.fjorum.model.entity.Category; import org.fjorum.model.entity.Topic; import org.fjorum.model.entity.User; import org.fjorum.model.repository.TopicRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; package org.fjorum.model.service; @Service public class TopicServiceImpl extends AbstractEntityServiceImpl<Topic> implements TopicService { private final TopicRepository topicRepository; @Autowired public TopicServiceImpl(TopicRepository topicRepository) { this.topicRepository = topicRepository; } @Override
public Topic createNewTopic(TopicCreateForm form) {
fjorum/fjorum
src/main/java/org/fjorum/controller/AdminController.java
// Path: src/main/java/org/fjorum/model/service/RoleService.java // public interface RoleService { // List<Role> getAllRoles(); // // Role addRole(Role role); // // Optional<Role> findRole(String name); // }
import org.fjorum.controller.form.*; import org.fjorum.model.entity.User; import org.fjorum.model.service.RoleService; import org.fjorum.model.service.UserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import javax.validation.Valid; import java.util.Comparator; import java.util.List; import java.util.NoSuchElementException; import java.util.stream.Collectors;
package org.fjorum.controller; @Controller @RequestMapping("/admin") public class AdminController { private static final String ADMIN_PAGE = "admin"; private static final String REDIRECT_ADMIN_PAGE = "redirect:/admin"; private static final String USER_DELETE_FORM_NAME = "userDeleteForm"; private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final UserService userService;
// Path: src/main/java/org/fjorum/model/service/RoleService.java // public interface RoleService { // List<Role> getAllRoles(); // // Role addRole(Role role); // // Optional<Role> findRole(String name); // } // Path: src/main/java/org/fjorum/controller/AdminController.java import org.fjorum.controller.form.*; import org.fjorum.model.entity.User; import org.fjorum.model.service.RoleService; import org.fjorum.model.service.UserService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import javax.validation.Valid; import java.util.Comparator; import java.util.List; import java.util.NoSuchElementException; import java.util.stream.Collectors; package org.fjorum.controller; @Controller @RequestMapping("/admin") public class AdminController { private static final String ADMIN_PAGE = "admin"; private static final String REDIRECT_ADMIN_PAGE = "redirect:/admin"; private static final String USER_DELETE_FORM_NAME = "userDeleteForm"; private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final UserService userService;
private final RoleService roleService;
fjorum/fjorum
src/main/java/org/fjorum/model/service/RoleServiceImpl.java
// Path: src/main/java/org/fjorum/model/entity/Role.java // @Entity // @Table(name = "roles") // public class Role { // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "id", nullable = false) // private Long id; // @Column(name = "name", nullable = false) // private String name; // @Column(name = "description") // private String descriptionKey; // @Column(name = "predefined") // boolean predefined; // // @ManyToMany(cascade = CascadeType.MERGE) // @JoinTable(name = "included_roles", // joinColumns = @JoinColumn(name = "role_id"), // inverseJoinColumns = @JoinColumn(name = "included_role_id")) // private Set<Role> includesRoles = new HashSet<>(); // // Role() { // } // // public Role(String name, String descriptionKey, boolean predefined) { // this.name = name; // this.descriptionKey = descriptionKey; // this.predefined = predefined; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getDescriptionKey() { // return descriptionKey; // } // // public void setDescriptionKey(String descriptionKey) { // this.descriptionKey = descriptionKey; // } // // public boolean isPredefined() { // return predefined; // } // // public void setPredefined(boolean predefined) { // this.predefined = predefined; // } // // public Set<Role> getIncludedRoles() { // return includesRoles; // } // // public void setIncludedRoles(Set<Role> includedRoles) { // this.includesRoles = includedRoles; // } // // public Set<Role> getAllRoles() { // return Stream.concat(Stream.of(this), // includesRoles.stream().flatMap(role -> role.getAllRoles().stream())) // .collect(Collectors.toSet()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || !(o instanceof Role)) return false; // // Role role = (Role) o; // // return id != null && id.equals(role.id); // } // // @Override // public int hashCode() { // return id != null ? id.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/org/fjorum/model/repository/RoleRepository.java // public interface RoleRepository extends JpaRepository<Role, String> { // Optional<Role> findOneByName(String name); // }
import java.util.List; import java.util.Optional; import org.fjorum.model.entity.Role; import org.fjorum.model.repository.RoleRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
package org.fjorum.model.service; @Service public class RoleServiceImpl implements RoleService {
// Path: src/main/java/org/fjorum/model/entity/Role.java // @Entity // @Table(name = "roles") // public class Role { // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "id", nullable = false) // private Long id; // @Column(name = "name", nullable = false) // private String name; // @Column(name = "description") // private String descriptionKey; // @Column(name = "predefined") // boolean predefined; // // @ManyToMany(cascade = CascadeType.MERGE) // @JoinTable(name = "included_roles", // joinColumns = @JoinColumn(name = "role_id"), // inverseJoinColumns = @JoinColumn(name = "included_role_id")) // private Set<Role> includesRoles = new HashSet<>(); // // Role() { // } // // public Role(String name, String descriptionKey, boolean predefined) { // this.name = name; // this.descriptionKey = descriptionKey; // this.predefined = predefined; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getDescriptionKey() { // return descriptionKey; // } // // public void setDescriptionKey(String descriptionKey) { // this.descriptionKey = descriptionKey; // } // // public boolean isPredefined() { // return predefined; // } // // public void setPredefined(boolean predefined) { // this.predefined = predefined; // } // // public Set<Role> getIncludedRoles() { // return includesRoles; // } // // public void setIncludedRoles(Set<Role> includedRoles) { // this.includesRoles = includedRoles; // } // // public Set<Role> getAllRoles() { // return Stream.concat(Stream.of(this), // includesRoles.stream().flatMap(role -> role.getAllRoles().stream())) // .collect(Collectors.toSet()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || !(o instanceof Role)) return false; // // Role role = (Role) o; // // return id != null && id.equals(role.id); // } // // @Override // public int hashCode() { // return id != null ? id.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/org/fjorum/model/repository/RoleRepository.java // public interface RoleRepository extends JpaRepository<Role, String> { // Optional<Role> findOneByName(String name); // } // Path: src/main/java/org/fjorum/model/service/RoleServiceImpl.java import java.util.List; import java.util.Optional; import org.fjorum.model.entity.Role; import org.fjorum.model.repository.RoleRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; package org.fjorum.model.service; @Service public class RoleServiceImpl implements RoleService {
private final RoleRepository roleRepository;
fjorum/fjorum
src/main/java/org/fjorum/model/service/RoleServiceImpl.java
// Path: src/main/java/org/fjorum/model/entity/Role.java // @Entity // @Table(name = "roles") // public class Role { // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "id", nullable = false) // private Long id; // @Column(name = "name", nullable = false) // private String name; // @Column(name = "description") // private String descriptionKey; // @Column(name = "predefined") // boolean predefined; // // @ManyToMany(cascade = CascadeType.MERGE) // @JoinTable(name = "included_roles", // joinColumns = @JoinColumn(name = "role_id"), // inverseJoinColumns = @JoinColumn(name = "included_role_id")) // private Set<Role> includesRoles = new HashSet<>(); // // Role() { // } // // public Role(String name, String descriptionKey, boolean predefined) { // this.name = name; // this.descriptionKey = descriptionKey; // this.predefined = predefined; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getDescriptionKey() { // return descriptionKey; // } // // public void setDescriptionKey(String descriptionKey) { // this.descriptionKey = descriptionKey; // } // // public boolean isPredefined() { // return predefined; // } // // public void setPredefined(boolean predefined) { // this.predefined = predefined; // } // // public Set<Role> getIncludedRoles() { // return includesRoles; // } // // public void setIncludedRoles(Set<Role> includedRoles) { // this.includesRoles = includedRoles; // } // // public Set<Role> getAllRoles() { // return Stream.concat(Stream.of(this), // includesRoles.stream().flatMap(role -> role.getAllRoles().stream())) // .collect(Collectors.toSet()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || !(o instanceof Role)) return false; // // Role role = (Role) o; // // return id != null && id.equals(role.id); // } // // @Override // public int hashCode() { // return id != null ? id.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/org/fjorum/model/repository/RoleRepository.java // public interface RoleRepository extends JpaRepository<Role, String> { // Optional<Role> findOneByName(String name); // }
import java.util.List; import java.util.Optional; import org.fjorum.model.entity.Role; import org.fjorum.model.repository.RoleRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;
package org.fjorum.model.service; @Service public class RoleServiceImpl implements RoleService { private final RoleRepository roleRepository; @Autowired public RoleServiceImpl(RoleRepository roleRepository) { this.roleRepository = roleRepository; } @Override
// Path: src/main/java/org/fjorum/model/entity/Role.java // @Entity // @Table(name = "roles") // public class Role { // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "id", nullable = false) // private Long id; // @Column(name = "name", nullable = false) // private String name; // @Column(name = "description") // private String descriptionKey; // @Column(name = "predefined") // boolean predefined; // // @ManyToMany(cascade = CascadeType.MERGE) // @JoinTable(name = "included_roles", // joinColumns = @JoinColumn(name = "role_id"), // inverseJoinColumns = @JoinColumn(name = "included_role_id")) // private Set<Role> includesRoles = new HashSet<>(); // // Role() { // } // // public Role(String name, String descriptionKey, boolean predefined) { // this.name = name; // this.descriptionKey = descriptionKey; // this.predefined = predefined; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getDescriptionKey() { // return descriptionKey; // } // // public void setDescriptionKey(String descriptionKey) { // this.descriptionKey = descriptionKey; // } // // public boolean isPredefined() { // return predefined; // } // // public void setPredefined(boolean predefined) { // this.predefined = predefined; // } // // public Set<Role> getIncludedRoles() { // return includesRoles; // } // // public void setIncludedRoles(Set<Role> includedRoles) { // this.includesRoles = includedRoles; // } // // public Set<Role> getAllRoles() { // return Stream.concat(Stream.of(this), // includesRoles.stream().flatMap(role -> role.getAllRoles().stream())) // .collect(Collectors.toSet()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || !(o instanceof Role)) return false; // // Role role = (Role) o; // // return id != null && id.equals(role.id); // } // // @Override // public int hashCode() { // return id != null ? id.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // // Path: src/main/java/org/fjorum/model/repository/RoleRepository.java // public interface RoleRepository extends JpaRepository<Role, String> { // Optional<Role> findOneByName(String name); // } // Path: src/main/java/org/fjorum/model/service/RoleServiceImpl.java import java.util.List; import java.util.Optional; import org.fjorum.model.entity.Role; import org.fjorum.model.repository.RoleRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; package org.fjorum.model.service; @Service public class RoleServiceImpl implements RoleService { private final RoleRepository roleRepository; @Autowired public RoleServiceImpl(RoleRepository roleRepository) { this.roleRepository = roleRepository; } @Override
public List<Role> getAllRoles() {
fjorum/fjorum
src/main/java/org/fjorum/model/service/CurrentUser.java
// Path: src/main/java/org/fjorum/model/entity/Role.java // @Entity // @Table(name = "roles") // public class Role { // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "id", nullable = false) // private Long id; // @Column(name = "name", nullable = false) // private String name; // @Column(name = "description") // private String descriptionKey; // @Column(name = "predefined") // boolean predefined; // // @ManyToMany(cascade = CascadeType.MERGE) // @JoinTable(name = "included_roles", // joinColumns = @JoinColumn(name = "role_id"), // inverseJoinColumns = @JoinColumn(name = "included_role_id")) // private Set<Role> includesRoles = new HashSet<>(); // // Role() { // } // // public Role(String name, String descriptionKey, boolean predefined) { // this.name = name; // this.descriptionKey = descriptionKey; // this.predefined = predefined; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getDescriptionKey() { // return descriptionKey; // } // // public void setDescriptionKey(String descriptionKey) { // this.descriptionKey = descriptionKey; // } // // public boolean isPredefined() { // return predefined; // } // // public void setPredefined(boolean predefined) { // this.predefined = predefined; // } // // public Set<Role> getIncludedRoles() { // return includesRoles; // } // // public void setIncludedRoles(Set<Role> includedRoles) { // this.includesRoles = includedRoles; // } // // public Set<Role> getAllRoles() { // return Stream.concat(Stream.of(this), // includesRoles.stream().flatMap(role -> role.getAllRoles().stream())) // .collect(Collectors.toSet()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || !(o instanceof Role)) return false; // // Role role = (Role) o; // // return id != null && id.equals(role.id); // } // // @Override // public int hashCode() { // return id != null ? id.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // }
import org.fjorum.model.entity.Role; import org.fjorum.model.entity.User; import org.springframework.security.core.authority.AuthorityUtils; import java.util.Set; import java.util.stream.Collectors;
package org.fjorum.model.service; public class CurrentUser extends org.springframework.security.core.userdetails.User { private User user; public CurrentUser(User user) { super(user.getEmail(), user.getPasswordHash(), user.isActive(), true, true, true, AuthorityUtils.createAuthorityList(getRoles(user))); this.user = user; } public User getUser() { return user; } public Long getId() { return user.getId(); } public String getName() { return user.getName(); } public Set<String> getRoles() { return user.getRoles().stream() .flatMap(role -> role.getAllRoles().stream())
// Path: src/main/java/org/fjorum/model/entity/Role.java // @Entity // @Table(name = "roles") // public class Role { // @Id // @GeneratedValue(strategy = GenerationType.IDENTITY) // @Column(name = "id", nullable = false) // private Long id; // @Column(name = "name", nullable = false) // private String name; // @Column(name = "description") // private String descriptionKey; // @Column(name = "predefined") // boolean predefined; // // @ManyToMany(cascade = CascadeType.MERGE) // @JoinTable(name = "included_roles", // joinColumns = @JoinColumn(name = "role_id"), // inverseJoinColumns = @JoinColumn(name = "included_role_id")) // private Set<Role> includesRoles = new HashSet<>(); // // Role() { // } // // public Role(String name, String descriptionKey, boolean predefined) { // this.name = name; // this.descriptionKey = descriptionKey; // this.predefined = predefined; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getDescriptionKey() { // return descriptionKey; // } // // public void setDescriptionKey(String descriptionKey) { // this.descriptionKey = descriptionKey; // } // // public boolean isPredefined() { // return predefined; // } // // public void setPredefined(boolean predefined) { // this.predefined = predefined; // } // // public Set<Role> getIncludedRoles() { // return includesRoles; // } // // public void setIncludedRoles(Set<Role> includedRoles) { // this.includesRoles = includedRoles; // } // // public Set<Role> getAllRoles() { // return Stream.concat(Stream.of(this), // includesRoles.stream().flatMap(role -> role.getAllRoles().stream())) // .collect(Collectors.toSet()); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (o == null || !(o instanceof Role)) return false; // // Role role = (Role) o; // // return id != null && id.equals(role.id); // } // // @Override // public int hashCode() { // return id != null ? id.hashCode() : 0; // } // // @Override // public String toString() { // return name; // } // } // Path: src/main/java/org/fjorum/model/service/CurrentUser.java import org.fjorum.model.entity.Role; import org.fjorum.model.entity.User; import org.springframework.security.core.authority.AuthorityUtils; import java.util.Set; import java.util.stream.Collectors; package org.fjorum.model.service; public class CurrentUser extends org.springframework.security.core.userdetails.User { private User user; public CurrentUser(User user) { super(user.getEmail(), user.getPasswordHash(), user.isActive(), true, true, true, AuthorityUtils.createAuthorityList(getRoles(user))); this.user = user; } public User getUser() { return user; } public Long getId() { return user.getId(); } public String getName() { return user.getName(); } public Set<String> getRoles() { return user.getRoles().stream() .flatMap(role -> role.getAllRoles().stream())
.map(Role::getName)
fjorum/fjorum
src/main/java/org/fjorum/model/service/CategoryServiceImpl.java
// Path: src/main/java/org/fjorum/controller/form/CategoryCreateForm.java // public class CategoryCreateForm { // // public final static String NAME = "categoryCreateForm"; // // @NotNull // private Category parentCategory; // // @NotEmpty // private String categoryName = ""; // // CategoryCreateForm(){} // // public CategoryCreateForm(Category parentCategory){ // this.parentCategory = parentCategory; // } // // public Category getParentCategory() { // return parentCategory; // } // // public void setParentCategory(Category parentCategory) { // this.parentCategory = parentCategory; // } // // public String getCategoryName() { // return categoryName; // } // // public void setCategoryName(String categoryName) { // this.categoryName = categoryName; // } // } // // Path: src/main/java/org/fjorum/model/repository/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long> { // // @Query("SELECT c FROM Category c WHERE c.parent is null") // Category getRoot(); // // }
import org.fjorum.controller.form.CategoryCreateForm; import org.fjorum.model.entity.Category; import org.fjorum.model.repository.CategoryRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service;
package org.fjorum.model.service; @Service public class CategoryServiceImpl extends AbstractEntityServiceImpl<Category> implements CategoryService {
// Path: src/main/java/org/fjorum/controller/form/CategoryCreateForm.java // public class CategoryCreateForm { // // public final static String NAME = "categoryCreateForm"; // // @NotNull // private Category parentCategory; // // @NotEmpty // private String categoryName = ""; // // CategoryCreateForm(){} // // public CategoryCreateForm(Category parentCategory){ // this.parentCategory = parentCategory; // } // // public Category getParentCategory() { // return parentCategory; // } // // public void setParentCategory(Category parentCategory) { // this.parentCategory = parentCategory; // } // // public String getCategoryName() { // return categoryName; // } // // public void setCategoryName(String categoryName) { // this.categoryName = categoryName; // } // } // // Path: src/main/java/org/fjorum/model/repository/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long> { // // @Query("SELECT c FROM Category c WHERE c.parent is null") // Category getRoot(); // // } // Path: src/main/java/org/fjorum/model/service/CategoryServiceImpl.java import org.fjorum.controller.form.CategoryCreateForm; import org.fjorum.model.entity.Category; import org.fjorum.model.repository.CategoryRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; package org.fjorum.model.service; @Service public class CategoryServiceImpl extends AbstractEntityServiceImpl<Category> implements CategoryService {
private final CategoryRepository categoryRepository;
fjorum/fjorum
src/main/java/org/fjorum/model/service/CategoryServiceImpl.java
// Path: src/main/java/org/fjorum/controller/form/CategoryCreateForm.java // public class CategoryCreateForm { // // public final static String NAME = "categoryCreateForm"; // // @NotNull // private Category parentCategory; // // @NotEmpty // private String categoryName = ""; // // CategoryCreateForm(){} // // public CategoryCreateForm(Category parentCategory){ // this.parentCategory = parentCategory; // } // // public Category getParentCategory() { // return parentCategory; // } // // public void setParentCategory(Category parentCategory) { // this.parentCategory = parentCategory; // } // // public String getCategoryName() { // return categoryName; // } // // public void setCategoryName(String categoryName) { // this.categoryName = categoryName; // } // } // // Path: src/main/java/org/fjorum/model/repository/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long> { // // @Query("SELECT c FROM Category c WHERE c.parent is null") // Category getRoot(); // // }
import org.fjorum.controller.form.CategoryCreateForm; import org.fjorum.model.entity.Category; import org.fjorum.model.repository.CategoryRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service;
package org.fjorum.model.service; @Service public class CategoryServiceImpl extends AbstractEntityServiceImpl<Category> implements CategoryService { private final CategoryRepository categoryRepository; @Autowired public CategoryServiceImpl(CategoryRepository categoryRepository) { this.categoryRepository = categoryRepository; } @Override public Category createNewCategory(String name, Category parent) { Category category = new Category(name, parent); return categoryRepository.save(category); } @Override
// Path: src/main/java/org/fjorum/controller/form/CategoryCreateForm.java // public class CategoryCreateForm { // // public final static String NAME = "categoryCreateForm"; // // @NotNull // private Category parentCategory; // // @NotEmpty // private String categoryName = ""; // // CategoryCreateForm(){} // // public CategoryCreateForm(Category parentCategory){ // this.parentCategory = parentCategory; // } // // public Category getParentCategory() { // return parentCategory; // } // // public void setParentCategory(Category parentCategory) { // this.parentCategory = parentCategory; // } // // public String getCategoryName() { // return categoryName; // } // // public void setCategoryName(String categoryName) { // this.categoryName = categoryName; // } // } // // Path: src/main/java/org/fjorum/model/repository/CategoryRepository.java // public interface CategoryRepository extends JpaRepository<Category, Long> { // // @Query("SELECT c FROM Category c WHERE c.parent is null") // Category getRoot(); // // } // Path: src/main/java/org/fjorum/model/service/CategoryServiceImpl.java import org.fjorum.controller.form.CategoryCreateForm; import org.fjorum.model.entity.Category; import org.fjorum.model.repository.CategoryRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Service; package org.fjorum.model.service; @Service public class CategoryServiceImpl extends AbstractEntityServiceImpl<Category> implements CategoryService { private final CategoryRepository categoryRepository; @Autowired public CategoryServiceImpl(CategoryRepository categoryRepository) { this.categoryRepository = categoryRepository; } @Override public Category createNewCategory(String name, Category parent) { Category category = new Category(name, parent); return categoryRepository.save(category); } @Override
public Category createNewCategory(CategoryCreateForm form) {
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
package com.github.markusbernhardt.xmldoclet; /** * Unit test group for Classes */ @SuppressWarnings("deprecation") public class ClassTest extends AbstractTestParent { /** * Testing nested Annotations * @see ClassAnnotationCascade */ @Test public void testClassAnnotationCascade() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertEquals(packageNode.getComment(), null); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getClazz().size(), 1); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; package com.github.markusbernhardt.xmldoclet; /** * Unit test group for Classes */ @SuppressWarnings("deprecation") public class ClassTest extends AbstractTestParent { /** * Testing nested Annotations * @see ClassAnnotationCascade */ @Test public void testClassAnnotationCascade() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertEquals(packageNode.getComment(), null); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getClazz().size(), 1); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0);
assertEquals("ClassAnnotationCascade", classNode.getComment());
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
/** * Rigourous Parser :-) */ @Test public void testSampledoc() { executeJavadoc(".", new String[] { "./src/test/java" }, null, null, new String[] { "com" }, new String[] { "-dryrun" }); } /** * testing a class with nothing defined EMPIRICAL OBSERVATION: The default * constructor created by the java compiler is not marked synthetic. um * what? */ @Test public void testClass1() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; /** * Rigourous Parser :-) */ @Test public void testSampledoc() { executeJavadoc(".", new String[] { "./src/test/java" }, null, null, new String[] { "com" }, new String[] { "-dryrun" }); } /** * testing a class with nothing defined EMPIRICAL OBSERVATION: The default * constructor created by the java compiler is not marked synthetic. um * what? */ @Test public void testClass1() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
assertEquals(classNode.getComment(), "Class1");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertFalse(classNode.isException()); assertFalse(classNode.isError()); assertEquals(classNode.getGeneric().size(), 0); assertEquals(constructor.getComment(), "Constructor1"); assertEquals(constructor.getName(), "Class2"); assertEquals(constructor.getParameter().size(), 0); assertEquals(constructor.getAnnotation().size(), 0); } /** * testing a class with 1 method */ @Test public void testClass3() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); Method method = classNode.getMethod().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertFalse(classNode.isException()); assertFalse(classNode.isError()); assertEquals(classNode.getGeneric().size(), 0); assertEquals(constructor.getComment(), "Constructor1"); assertEquals(constructor.getName(), "Class2"); assertEquals(constructor.getParameter().size(), 0); assertEquals(constructor.getAnnotation().size(), 0); } /** * testing a class with 1 method */ @Test public void testClass3() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); Method method = classNode.getMethod().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
assertEquals(classNode.getComment(), "Class3");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertEquals(method.getParameter().size(), 0); assertEquals(method.getException().size(), 0); TypeInfo returnNode = method.getReturn(); assertEquals(returnNode.getQualified(), "int"); assertNull(returnNode.getDimension()); assertEquals(returnNode.getGeneric().size(), 0); assertNull(returnNode.getWildcard()); } /** * testing a class with 1 field */ @Test public void testClass4() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); Field field = classNode.getField().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertEquals(method.getParameter().size(), 0); assertEquals(method.getException().size(), 0); TypeInfo returnNode = method.getReturn(); assertEquals(returnNode.getQualified(), "int"); assertNull(returnNode.getDimension()); assertEquals(returnNode.getGeneric().size(), 0); assertNull(returnNode.getWildcard()); } /** * testing a class with 1 field */ @Test public void testClass4() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); Field field = classNode.getField().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
assertEquals(classNode.getComment(), "Class4");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertNull(field.getType().getWildcard()); assertFalse(field.isStatic()); assertFalse(field.isTransient()); assertFalse(field.isVolatile()); assertFalse(field.isFinal()); assertNull(field.getConstant()); assertEquals(field.getAnnotation().size(), 0); } /** * testing a class that extends another class with 1 method */ @Test public void testClass5() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java", "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 2);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertNull(field.getType().getWildcard()); assertFalse(field.isStatic()); assertFalse(field.isTransient()); assertFalse(field.isVolatile()); assertFalse(field.isFinal()); assertNull(field.getConstant()); assertEquals(field.getAnnotation().size(), 0); } /** * testing a class that extends another class with 1 method */ @Test public void testClass5() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java", "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 2);
assertEquals(classNode.getComment(), "Class5");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertFalse(classNode.isSerializable()); assertFalse(classNode.isException()); assertFalse(classNode.isError()); assertEquals(classNode.getGeneric().size(), 0); // test annotation 'deprecated' on class assertEquals(annotationNode.getQualified(), "java.lang.Deprecated"); assertEquals(annotationNode.getName(), "Deprecated"); assertEquals(annotationNode.getArgument().size(), 0); } /** * testing abstract keyword on class */ @Test public void testClass8() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertFalse(classNode.isSerializable()); assertFalse(classNode.isException()); assertFalse(classNode.isError()); assertEquals(classNode.getGeneric().size(), 0); // test annotation 'deprecated' on class assertEquals(annotationNode.getQualified(), "java.lang.Deprecated"); assertEquals(annotationNode.getName(), "Deprecated"); assertEquals(annotationNode.getArgument().size(), 0); } /** * testing abstract keyword on class */ @Test public void testClass8() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
assertEquals(classNode.getComment(), "Class8");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertEquals(classNode.getInterface().size(), 0); assertEquals(classNode.getClazz().getQualified(), Object.class.getName()); assertTrue(classNode.isAbstract()); assertFalse(classNode.isExternalizable()); assertTrue(classNode.isIncluded()); assertFalse(classNode.isSerializable()); assertFalse(classNode.isException()); assertFalse(classNode.isError()); assertEquals(classNode.getGeneric().size(), 0); } /** * testing java.io.Externalizable interface on class */ @Test public void testClass9() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class1.java // public class Class1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class3.java // public class Class3 { // /** // * method1 // * // * @return int // */ // public int method1() { // return 0; // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class4.java // public class Class4 { // /** // * field1 // */ // public int field1; // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class5.java // public class Class5 extends Class3 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class6.java // @SuppressWarnings("serial") // public class Class6 implements java.io.Serializable { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class8.java // public abstract class Class8 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java // public class Class9 implements java.io.Externalizable { // // public void writeExternal(ObjectOutput out) throws IOException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { // // To change body of implemented methods use File | Settings | File // // Templates. // } // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/ClassAnnotationCascade.java // @AnnotationCascade( // children= { // @AnnotationCascadeChild(name="primitive", // dummyData= {"A", "B", "C"} // ), // @AnnotationCascadeChild(name="nested", // subAnnotations= { // @Annotation3(id=4), // @Annotation3(id=5), // @Annotation3(id=666) // // }) // } // ) // public class ClassAnnotationCascade implements Interface2 { // // public void test() { // // } // // /** // * {@inheritDoc} // */ // @Override // public int method1() { // return 0; // } // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/ClassTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Annotation3; import com.github.markusbernhardt.xmldoclet.simpledata.AnnotationCascadeChild; import com.github.markusbernhardt.xmldoclet.simpledata.Class1; import com.github.markusbernhardt.xmldoclet.simpledata.Class2; import com.github.markusbernhardt.xmldoclet.simpledata.Class3; import com.github.markusbernhardt.xmldoclet.simpledata.Class4; import com.github.markusbernhardt.xmldoclet.simpledata.Class5; import com.github.markusbernhardt.xmldoclet.simpledata.Class6; import com.github.markusbernhardt.xmldoclet.simpledata.Class7; import com.github.markusbernhardt.xmldoclet.simpledata.Class8; import com.github.markusbernhardt.xmldoclet.simpledata.Class9; import com.github.markusbernhardt.xmldoclet.simpledata.ClassAnnotationCascade; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationArgument; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Class; import com.github.markusbernhardt.xmldoclet.xjc.Constructor; import com.github.markusbernhardt.xmldoclet.xjc.Field; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeInfo; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertEquals(classNode.getInterface().size(), 0); assertEquals(classNode.getClazz().getQualified(), Object.class.getName()); assertTrue(classNode.isAbstract()); assertFalse(classNode.isExternalizable()); assertTrue(classNode.isIncluded()); assertFalse(classNode.isSerializable()); assertFalse(classNode.isException()); assertFalse(classNode.isError()); assertEquals(classNode.getGeneric().size(), 0); } /** * testing java.io.Externalizable interface on class */ @Test public void testClass9() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Class9.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Class classNode = packageNode.getClazz().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 0); assertEquals(packageNode.getClazz().size(), 1);
assertEquals(classNode.getComment(), "Class9");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
package com.github.markusbernhardt.xmldoclet; /** * Unit test group for Interfaces */ @SuppressWarnings("deprecation") public class InterfaceTest extends AbstractTestParent { /** * Rigourous Parser :-) */ @Test public void testSampledoc() { executeJavadoc(".", new String[] { "./src/test/java" }, null, null, new String[] { "com" }, new String[] { "-dryrun" }); } /** * testing a interface with nothing defined */ @Test public void testInterface1() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; package com.github.markusbernhardt.xmldoclet; /** * Unit test group for Interfaces */ @SuppressWarnings("deprecation") public class InterfaceTest extends AbstractTestParent { /** * Rigourous Parser :-) */ @Test public void testSampledoc() { executeJavadoc(".", new String[] { "./src/test/java" }, null, null, new String[] { "com" }, new String[] { "-dryrun" }); } /** * testing a interface with nothing defined */ @Test public void testInterface1() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
assertEquals(interfaceNode.getComment(), "Interface1");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertEquals(interfaceNode.getComment(), "Interface1"); assertEquals(interfaceNode.getName(), Interface1.class.getSimpleName()); assertEquals(interfaceNode.getQualified(), Interface1.class.getName()); assertEquals(interfaceNode.getScope(), "public"); assertEquals(interfaceNode.getMethod().size(), 0); assertEquals(interfaceNode.getAnnotation().size(), 0); assertEquals(interfaceNode.getInterface().size(), 0); assertTrue(interfaceNode.isIncluded()); } /** * testing a interface with 1 method */ @Test public void testInterface2() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); Method method = interfaceNode.getMethod().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertEquals(interfaceNode.getComment(), "Interface1"); assertEquals(interfaceNode.getName(), Interface1.class.getSimpleName()); assertEquals(interfaceNode.getQualified(), Interface1.class.getName()); assertEquals(interfaceNode.getScope(), "public"); assertEquals(interfaceNode.getMethod().size(), 0); assertEquals(interfaceNode.getAnnotation().size(), 0); assertEquals(interfaceNode.getInterface().size(), 0); assertTrue(interfaceNode.isIncluded()); } /** * testing a interface with 1 method */ @Test public void testInterface2() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); Method method = interfaceNode.getMethod().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
assertEquals(interfaceNode.getComment(), "Interface2");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertFalse(method.isStatic()); assertFalse(method.isSynchronized()); assertFalse(method.isVarArgs()); assertEquals(method.getQualified(), "com.github.markusbernhardt.xmldoclet.simpledata.Interface2.method1"); assertEquals(method.getScope(), "public"); assertEquals(method.getAnnotation().size(), 0); assertEquals(method.getParameter().size(), 0); assertEquals(method.getException().size(), 0); } /** * testing a interface that extends another interface */ @Test public void testInterface3() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertFalse(method.isStatic()); assertFalse(method.isSynchronized()); assertFalse(method.isVarArgs()); assertEquals(method.getQualified(), "com.github.markusbernhardt.xmldoclet.simpledata.Interface2.method1"); assertEquals(method.getScope(), "public"); assertEquals(method.getAnnotation().size(), 0); assertEquals(method.getParameter().size(), 0); assertEquals(method.getException().size(), 0); } /** * testing a interface that extends another interface */ @Test public void testInterface3() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
assertEquals(interfaceNode.getComment(), "Interface3");
MarkusBernhardt/xml-doclet
src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter;
assertEquals(interfaceNode.getScope(), "public"); assertEquals(interfaceNode.getMethod().size(), 0); assertEquals(interfaceNode.getAnnotation().size(), 0); assertEquals(interfaceNode.getInterface().size(), 1); assertTrue(interfaceNode.isIncluded()); // verify interface assertEquals(interfaceNode.getInterface().get(0).getQualified(), java.io.Serializable.class.getName()); } /** * testing a interface that implements one annotation */ @Test public void testInterface4() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); AnnotationInstance annotationInstanceNode = interfaceNode.getAnnotation().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
// Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface1.java // public interface Interface1 { // // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface2.java // public interface Interface2 { // /** // * method1 // * // * @return int // */ // public int method1(); // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface3.java // public interface Interface3 extends java.io.Serializable { // } // // Path: src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java // @Deprecated // public interface Interface4 { // } // Path: src/test/java/com/github/markusbernhardt/xmldoclet/InterfaceTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.junit.Test; import com.github.markusbernhardt.xmldoclet.simpledata.Interface1; import com.github.markusbernhardt.xmldoclet.simpledata.Interface2; import com.github.markusbernhardt.xmldoclet.simpledata.Interface3; import com.github.markusbernhardt.xmldoclet.simpledata.Interface4; import com.github.markusbernhardt.xmldoclet.xjc.AnnotationInstance; import com.github.markusbernhardt.xmldoclet.xjc.Interface; import com.github.markusbernhardt.xmldoclet.xjc.Method; import com.github.markusbernhardt.xmldoclet.xjc.Package; import com.github.markusbernhardt.xmldoclet.xjc.Root; import com.github.markusbernhardt.xmldoclet.xjc.TypeParameter; assertEquals(interfaceNode.getScope(), "public"); assertEquals(interfaceNode.getMethod().size(), 0); assertEquals(interfaceNode.getAnnotation().size(), 0); assertEquals(interfaceNode.getInterface().size(), 1); assertTrue(interfaceNode.isIncluded()); // verify interface assertEquals(interfaceNode.getInterface().get(0).getQualified(), java.io.Serializable.class.getName()); } /** * testing a interface that implements one annotation */ @Test public void testInterface4() { String[] sourceFiles = new String[] { "./src/test/java/com/github/markusbernhardt/xmldoclet/simpledata/Interface4.java" }; Root rootNode = executeJavadoc(null, null, null, sourceFiles, null, new String[] { "-dryrun" }); Package packageNode = rootNode.getPackage().get(0); Interface interfaceNode = packageNode.getInterface().get(0); AnnotationInstance annotationInstanceNode = interfaceNode.getAnnotation().get(0); assertEquals(rootNode.getPackage().size(), 1); assertNull(packageNode.getComment()); assertEquals(packageNode.getName(), "com.github.markusbernhardt.xmldoclet.simpledata"); assertEquals(packageNode.getAnnotation().size(), 0); assertEquals(packageNode.getEnum().size(), 0); assertEquals(packageNode.getInterface().size(), 1); assertEquals(packageNode.getClazz().size(), 0);
assertEquals(interfaceNode.getComment(), "Interface4");
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporter.java // public interface BigqueryFieldExporter { // // /** // * Called for each RequestLogs to be processed. Should store necessary state // * to respond to later {@link #getField(String) getField} calls. // * // * @param log entry to be processed // */ // public void processLog(RequestLogs log); // // /** // * Return the value of the given field for the last processed log. // * Any Object with a toString method that generates a BigQuery readable // * string is allowed. // * // * The String is interned so that the reference can be compared directly. // * // * @param name an intern'ed string returned from {@link #getFieldName(int) getFieldName} // * @return the field's value or null if the name is invalid // */ // public Object getField(String name); // // /** // * @return the number of fields generated by this exporter // */ // public int getFieldCount(); // // /** // * Indexing must be consistent with {@link #getFieldType(int) getFieldType}. // * // * @param i the field index // * @return the name of the i'th field // */ // public String getFieldName(int i); // // /** // * Indexing must be consistent with {@link #getFieldName(int) getFieldName}. // * // * @param i the field index // * @return the BigQuery data type of the i'th field // */ // public String getFieldType(int i); // // /** // * Determine this processed {@link RequestLogs} is either a App Log or Request Header(or body) Log // * @return If this processed {@link RequestLogs} is a App Log, return true. Otherwise return false. // */ // public boolean isAppLogProcessed(); // // /** // * Return processed log lines in {@link RequestLogs} // * @return List of Processed App Log Lines // */ // public List<String> getAppLogLines(); // // /** // * Move iterator for app log lines list to next position // * @return If go to end line, return false // */ // public boolean nextAppLogLine(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // }
import java.util.Arrays; import java.util.List; import com.google.appengine.api.log.RequestLogs; import com.l2bq.logging.analysis.BigqueryFieldExporter; import com.l2bq.logging.analysis.BigqueryFieldExporterSet;
/* * Copyright 2012 Rewardly Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.l2bq.logging.analysis.exporter.http; public class HttpFieldExporterSet implements BigqueryFieldExporterSet { @Override
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporter.java // public interface BigqueryFieldExporter { // // /** // * Called for each RequestLogs to be processed. Should store necessary state // * to respond to later {@link #getField(String) getField} calls. // * // * @param log entry to be processed // */ // public void processLog(RequestLogs log); // // /** // * Return the value of the given field for the last processed log. // * Any Object with a toString method that generates a BigQuery readable // * string is allowed. // * // * The String is interned so that the reference can be compared directly. // * // * @param name an intern'ed string returned from {@link #getFieldName(int) getFieldName} // * @return the field's value or null if the name is invalid // */ // public Object getField(String name); // // /** // * @return the number of fields generated by this exporter // */ // public int getFieldCount(); // // /** // * Indexing must be consistent with {@link #getFieldType(int) getFieldType}. // * // * @param i the field index // * @return the name of the i'th field // */ // public String getFieldName(int i); // // /** // * Indexing must be consistent with {@link #getFieldName(int) getFieldName}. // * // * @param i the field index // * @return the BigQuery data type of the i'th field // */ // public String getFieldType(int i); // // /** // * Determine this processed {@link RequestLogs} is either a App Log or Request Header(or body) Log // * @return If this processed {@link RequestLogs} is a App Log, return true. Otherwise return false. // */ // public boolean isAppLogProcessed(); // // /** // * Return processed log lines in {@link RequestLogs} // * @return List of Processed App Log Lines // */ // public List<String> getAppLogLines(); // // /** // * Move iterator for app log lines list to next position // * @return If go to end line, return false // */ // public boolean nextAppLogLine(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java import java.util.Arrays; import java.util.List; import com.google.appengine.api.log.RequestLogs; import com.l2bq.logging.analysis.BigqueryFieldExporter; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; /* * Copyright 2012 Rewardly Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.l2bq.logging.analysis.exporter.http; public class HttpFieldExporterSet implements BigqueryFieldExporterSet { @Override
public List<BigqueryFieldExporter> getExporters() {
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporter.java // public interface BigqueryFieldExporter { // // /** // * Called for each RequestLogs to be processed. Should store necessary state // * to respond to later {@link #getField(String) getField} calls. // * // * @param log entry to be processed // */ // public void processLog(RequestLogs log); // // /** // * Return the value of the given field for the last processed log. // * Any Object with a toString method that generates a BigQuery readable // * string is allowed. // * // * The String is interned so that the reference can be compared directly. // * // * @param name an intern'ed string returned from {@link #getFieldName(int) getFieldName} // * @return the field's value or null if the name is invalid // */ // public Object getField(String name); // // /** // * @return the number of fields generated by this exporter // */ // public int getFieldCount(); // // /** // * Indexing must be consistent with {@link #getFieldType(int) getFieldType}. // * // * @param i the field index // * @return the name of the i'th field // */ // public String getFieldName(int i); // // /** // * Indexing must be consistent with {@link #getFieldName(int) getFieldName}. // * // * @param i the field index // * @return the BigQuery data type of the i'th field // */ // public String getFieldType(int i); // // /** // * Determine this processed {@link RequestLogs} is either a App Log or Request Header(or body) Log // * @return If this processed {@link RequestLogs} is a App Log, return true. Otherwise return false. // */ // public boolean isAppLogProcessed(); // // /** // * Return processed log lines in {@link RequestLogs} // * @return List of Processed App Log Lines // */ // public List<String> getAppLogLines(); // // /** // * Move iterator for app log lines list to next position // * @return If go to end line, return false // */ // public boolean nextAppLogLine(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // }
import java.util.Arrays; import java.util.List; import com.google.appengine.api.log.RequestLogs; import com.l2bq.logging.analysis.BigqueryFieldExporter; import com.l2bq.logging.analysis.BigqueryFieldExporterSet;
/* * Copyright 2012 Rewardly Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.l2bq.logging.analysis.exporter.applog.login; public class LoginExporterSet implements BigqueryFieldExporterSet { @Override
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporter.java // public interface BigqueryFieldExporter { // // /** // * Called for each RequestLogs to be processed. Should store necessary state // * to respond to later {@link #getField(String) getField} calls. // * // * @param log entry to be processed // */ // public void processLog(RequestLogs log); // // /** // * Return the value of the given field for the last processed log. // * Any Object with a toString method that generates a BigQuery readable // * string is allowed. // * // * The String is interned so that the reference can be compared directly. // * // * @param name an intern'ed string returned from {@link #getFieldName(int) getFieldName} // * @return the field's value or null if the name is invalid // */ // public Object getField(String name); // // /** // * @return the number of fields generated by this exporter // */ // public int getFieldCount(); // // /** // * Indexing must be consistent with {@link #getFieldType(int) getFieldType}. // * // * @param i the field index // * @return the name of the i'th field // */ // public String getFieldName(int i); // // /** // * Indexing must be consistent with {@link #getFieldName(int) getFieldName}. // * // * @param i the field index // * @return the BigQuery data type of the i'th field // */ // public String getFieldType(int i); // // /** // * Determine this processed {@link RequestLogs} is either a App Log or Request Header(or body) Log // * @return If this processed {@link RequestLogs} is a App Log, return true. Otherwise return false. // */ // public boolean isAppLogProcessed(); // // /** // * Return processed log lines in {@link RequestLogs} // * @return List of Processed App Log Lines // */ // public List<String> getAppLogLines(); // // /** // * Move iterator for app log lines list to next position // * @return If go to end line, return false // */ // public boolean nextAppLogLine(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java import java.util.Arrays; import java.util.List; import com.google.appengine.api.log.RequestLogs; import com.l2bq.logging.analysis.BigqueryFieldExporter; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; /* * Copyright 2012 Rewardly Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.l2bq.logging.analysis.exporter.applog.login; public class LoginExporterSet implements BigqueryFieldExporterSet { @Override
public List<BigqueryFieldExporter> getExporters() {
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/AnalysisUtility.java
// Path: src/main/java/com/l2bq/datastore/analysis/builtin/BuiltinDatastoreExportConfiguration.java // public interface BuiltinDatastoreExportConfiguration { // /** // * specifies which entity kinds should be exported to bigquery // * @return a list of strings, each representing the name of the entity kind // */ // public List<String> getEntityKindsToExport(); // // /** // * // * @return the bucket name you'd like the datastore backup stored to // */ // public String getBucketName(); // // /** // * // * @return the dataset in bigquery that you'd like tables created in for this datastore export // */ // public String getBigqueryDatasetId(); // // /** // * // * @return your project id available in the api console // */ // public String getBigqueryProjectId(); // // /** // * // * @return in bigquery whether or not to append the timestamp of the export to the // * names of the tables created in bigquery. If you wawant your export to overwrite // * previous exports in bigquery you should set this to false that way it overrides the last export. // */ // public boolean appendTimestampToDatatables(); // // /** // * // * @return the task queue to use for this job. Return null if you want to use default queue // */ // public String getQueueName(); // // /** // * Return true if you want to just use mache for automatic backup creation to cloud storage and not exporting to bigquery. Normally this should be set to false. // * @return whether or not to export to bigquery // */ // public boolean shouldSkipExportToBigquery(); // // /** // * This allows you to name the backups created in cloudstrage and the datastore admin console for future reference // * @return the name of the backup to be used in Google Cloud Storage, or null to use the default // */ // public String getBackupNamePrefix(); // }
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.nio.channels.Channels; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; import java.util.TimeZone; import javax.servlet.http.HttpServletRequest; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpRequestFactory; import com.google.api.client.http.HttpResponse; import com.google.appengine.api.datastore.Text; import com.google.appengine.api.files.AppEngineFile; import com.google.appengine.api.files.FileReadChannel; import com.google.appengine.api.files.FileService; import com.google.appengine.api.files.FileServiceFactory; import com.google.appengine.api.files.FileWriteChannel; import com.google.appengine.api.files.FinalizationException; import com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder; import com.google.appengine.api.files.LockException; import com.l2bq.datastore.analysis.builtin.BuiltinDatastoreExportConfiguration;
} return fixedPoint; } public static String loadSchemaStr(String schemaFileName) throws FileNotFoundException, LockException, IOException { FileService fileService = FileServiceFactory.getFileService(); AppEngineFile schemaFile = new AppEngineFile(schemaFileName); FileReadChannel readChannel = fileService.openReadChannel(schemaFile, false); BufferedReader reader = new BufferedReader(Channels.newReader(readChannel, "UTF8")); String schemaLine; try { schemaLine = reader.readLine().trim(); } catch (NullPointerException npe) { throw new IOException("Encountered NPE reading " + schemaFileName); } reader.close(); readChannel.close(); return schemaLine; } public static String failureJson(String message) { return "{\"success\":false, \"message\":\"" + message + "\"}"; } public static String successJson(String message) { return "{\"success\":true, \"message\":\"" + message + "\"}"; }
// Path: src/main/java/com/l2bq/datastore/analysis/builtin/BuiltinDatastoreExportConfiguration.java // public interface BuiltinDatastoreExportConfiguration { // /** // * specifies which entity kinds should be exported to bigquery // * @return a list of strings, each representing the name of the entity kind // */ // public List<String> getEntityKindsToExport(); // // /** // * // * @return the bucket name you'd like the datastore backup stored to // */ // public String getBucketName(); // // /** // * // * @return the dataset in bigquery that you'd like tables created in for this datastore export // */ // public String getBigqueryDatasetId(); // // /** // * // * @return your project id available in the api console // */ // public String getBigqueryProjectId(); // // /** // * // * @return in bigquery whether or not to append the timestamp of the export to the // * names of the tables created in bigquery. If you wawant your export to overwrite // * previous exports in bigquery you should set this to false that way it overrides the last export. // */ // public boolean appendTimestampToDatatables(); // // /** // * // * @return the task queue to use for this job. Return null if you want to use default queue // */ // public String getQueueName(); // // /** // * Return true if you want to just use mache for automatic backup creation to cloud storage and not exporting to bigquery. Normally this should be set to false. // * @return whether or not to export to bigquery // */ // public boolean shouldSkipExportToBigquery(); // // /** // * This allows you to name the backups created in cloudstrage and the datastore admin console for future reference // * @return the name of the backup to be used in Google Cloud Storage, or null to use the default // */ // public String getBackupNamePrefix(); // } // Path: src/main/java/com/l2bq/logging/analysis/AnalysisUtility.java import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.nio.channels.Channels; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.NumberFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; import java.util.TimeZone; import javax.servlet.http.HttpServletRequest; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpRequestFactory; import com.google.api.client.http.HttpResponse; import com.google.appengine.api.datastore.Text; import com.google.appengine.api.files.AppEngineFile; import com.google.appengine.api.files.FileReadChannel; import com.google.appengine.api.files.FileService; import com.google.appengine.api.files.FileServiceFactory; import com.google.appengine.api.files.FileWriteChannel; import com.google.appengine.api.files.FinalizationException; import com.google.appengine.api.files.GSFileOptions.GSFileOptionsBuilder; import com.google.appengine.api.files.LockException; import com.l2bq.datastore.analysis.builtin.BuiltinDatastoreExportConfiguration; } return fixedPoint; } public static String loadSchemaStr(String schemaFileName) throws FileNotFoundException, LockException, IOException { FileService fileService = FileServiceFactory.getFileService(); AppEngineFile schemaFile = new AppEngineFile(schemaFileName); FileReadChannel readChannel = fileService.openReadChannel(schemaFile, false); BufferedReader reader = new BufferedReader(Channels.newReader(readChannel, "UTF8")); String schemaLine; try { schemaLine = reader.readLine().trim(); } catch (NullPointerException npe) { throw new IOException("Encountered NPE reading " + schemaFileName); } reader.close(); readChannel.close(); return schemaLine; } public static String failureJson(String message) { return "{\"success\":false, \"message\":\"" + message + "\"}"; } public static String successJson(String message) { return "{\"success\":true, \"message\":\"" + message + "\"}"; }
public static BuiltinDatastoreExportConfiguration instantiateExportConfig(String builtinDatastoreExportConfig) {
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // }
import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet;
package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag {
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // } // Path: src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet; package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag {
private List<BigqueryFieldExporterSet> fieldExporterSet;
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // }
import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet;
package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag { private List<BigqueryFieldExporterSet> fieldExporterSet; public ExporterSetBag() { // TODO Auto-generated constructor stub } @Override public List<BigqueryFieldExporterSet> getExporterSetList() { fieldExporterSet = Arrays.asList(
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // } // Path: src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet; package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag { private List<BigqueryFieldExporterSet> fieldExporterSet; public ExporterSetBag() { // TODO Auto-generated constructor stub } @Override public List<BigqueryFieldExporterSet> getExporterSetList() { fieldExporterSet = Arrays.asList(
new HttpFieldExporterSet(),
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // }
import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet;
package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag { private List<BigqueryFieldExporterSet> fieldExporterSet; public ExporterSetBag() { // TODO Auto-generated constructor stub } @Override public List<BigqueryFieldExporterSet> getExporterSetList() { fieldExporterSet = Arrays.asList( new HttpFieldExporterSet(),
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // } // Path: src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet; package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag { private List<BigqueryFieldExporterSet> fieldExporterSet; public ExporterSetBag() { // TODO Auto-generated constructor stub } @Override public List<BigqueryFieldExporterSet> getExporterSetList() { fieldExporterSet = Arrays.asList( new HttpFieldExporterSet(),
new LoginExporterSet(),
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // }
import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet;
package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag { private List<BigqueryFieldExporterSet> fieldExporterSet; public ExporterSetBag() { // TODO Auto-generated constructor stub } @Override public List<BigqueryFieldExporterSet> getExporterSetList() { fieldExporterSet = Arrays.asList( new HttpFieldExporterSet(), new LoginExporterSet(),
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSetBag.java // public interface BigqueryFieldExporterSetBag { // // // /** // * Get the exporter Set in this BigqueryFieldExporterSetBag. // * // * @return the exporter set list in the bag // */ // public List<BigqueryFieldExporterSet> getExporterSetList(); // // /** // * Set the exporter set list in this BigqueryFieldExporterSetBag. // * @param setList the exporter set list to set // */ // public void setExporterSetList(List<BigqueryFieldExporterSet> setList); // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/login/LoginExporterSet.java // public class LoginExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new LoginExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_login"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java // public class SignupExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // (BigqueryFieldExporter)new SignupExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "applog_signup"; // } // // } // // Path: src/main/java/com/l2bq/logging/analysis/exporter/http/HttpFieldExporterSet.java // public class HttpFieldExporterSet implements BigqueryFieldExporterSet { // // @Override // public List<BigqueryFieldExporter> getExporters() { // return Arrays.asList( // new HttpTransactionFieldExporter(), // new InstanceFieldExporter(), // new PerformanceFieldExporter(), // new TimestampFieldExporter(), // new UrlFieldExporter(), // new UserFieldExporter(), // new VersionFieldExporter(), // new AppLogFieldExporter()); // } // // @Override // public boolean skipLog(RequestLogs log) // { // return false; // } // // @Override // public List<String> applicationVersionsToExport() { // return null; // } // // @Override // public String getPrefix() // { // return "http_access_log"; // } // // } // Path: src/main/java/com/l2bq/logging/analysis/exporter/ExporterSetBag.java import java.util.Arrays; import java.util.List; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; import com.l2bq.logging.analysis.BigqueryFieldExporterSetBag; import com.l2bq.logging.analysis.exporter.applog.login.LoginExporterSet; import com.l2bq.logging.analysis.exporter.applog.signup.SignupExporterSet; import com.l2bq.logging.analysis.exporter.http.HttpFieldExporterSet; package com.l2bq.logging.analysis.exporter; public class ExporterSetBag implements BigqueryFieldExporterSetBag { private List<BigqueryFieldExporterSet> fieldExporterSet; public ExporterSetBag() { // TODO Auto-generated constructor stub } @Override public List<BigqueryFieldExporterSet> getExporterSetList() { fieldExporterSet = Arrays.asList( new HttpFieldExporterSet(), new LoginExporterSet(),
new SignupExporterSet());
steveseo/l2bq
src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporter.java // public interface BigqueryFieldExporter { // // /** // * Called for each RequestLogs to be processed. Should store necessary state // * to respond to later {@link #getField(String) getField} calls. // * // * @param log entry to be processed // */ // public void processLog(RequestLogs log); // // /** // * Return the value of the given field for the last processed log. // * Any Object with a toString method that generates a BigQuery readable // * string is allowed. // * // * The String is interned so that the reference can be compared directly. // * // * @param name an intern'ed string returned from {@link #getFieldName(int) getFieldName} // * @return the field's value or null if the name is invalid // */ // public Object getField(String name); // // /** // * @return the number of fields generated by this exporter // */ // public int getFieldCount(); // // /** // * Indexing must be consistent with {@link #getFieldType(int) getFieldType}. // * // * @param i the field index // * @return the name of the i'th field // */ // public String getFieldName(int i); // // /** // * Indexing must be consistent with {@link #getFieldName(int) getFieldName}. // * // * @param i the field index // * @return the BigQuery data type of the i'th field // */ // public String getFieldType(int i); // // /** // * Determine this processed {@link RequestLogs} is either a App Log or Request Header(or body) Log // * @return If this processed {@link RequestLogs} is a App Log, return true. Otherwise return false. // */ // public boolean isAppLogProcessed(); // // /** // * Return processed log lines in {@link RequestLogs} // * @return List of Processed App Log Lines // */ // public List<String> getAppLogLines(); // // /** // * Move iterator for app log lines list to next position // * @return If go to end line, return false // */ // public boolean nextAppLogLine(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // }
import java.util.Arrays; import java.util.List; import com.google.appengine.api.log.RequestLogs; import com.l2bq.logging.analysis.BigqueryFieldExporter; import com.l2bq.logging.analysis.BigqueryFieldExporterSet;
package com.l2bq.logging.analysis.exporter.applog.signup; public class SignupExporterSet implements BigqueryFieldExporterSet { @Override
// Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporter.java // public interface BigqueryFieldExporter { // // /** // * Called for each RequestLogs to be processed. Should store necessary state // * to respond to later {@link #getField(String) getField} calls. // * // * @param log entry to be processed // */ // public void processLog(RequestLogs log); // // /** // * Return the value of the given field for the last processed log. // * Any Object with a toString method that generates a BigQuery readable // * string is allowed. // * // * The String is interned so that the reference can be compared directly. // * // * @param name an intern'ed string returned from {@link #getFieldName(int) getFieldName} // * @return the field's value or null if the name is invalid // */ // public Object getField(String name); // // /** // * @return the number of fields generated by this exporter // */ // public int getFieldCount(); // // /** // * Indexing must be consistent with {@link #getFieldType(int) getFieldType}. // * // * @param i the field index // * @return the name of the i'th field // */ // public String getFieldName(int i); // // /** // * Indexing must be consistent with {@link #getFieldName(int) getFieldName}. // * // * @param i the field index // * @return the BigQuery data type of the i'th field // */ // public String getFieldType(int i); // // /** // * Determine this processed {@link RequestLogs} is either a App Log or Request Header(or body) Log // * @return If this processed {@link RequestLogs} is a App Log, return true. Otherwise return false. // */ // public boolean isAppLogProcessed(); // // /** // * Return processed log lines in {@link RequestLogs} // * @return List of Processed App Log Lines // */ // public List<String> getAppLogLines(); // // /** // * Move iterator for app log lines list to next position // * @return If go to end line, return false // */ // public boolean nextAppLogLine(); // // } // // Path: src/main/java/com/l2bq/logging/analysis/BigqueryFieldExporterSet.java // public interface BigqueryFieldExporterSet { // /** // * Get the exporters in this BigqueryFieldExporterSet. // * // * @return the exporters in the set // */ // public List<BigqueryFieldExporter> getExporters(); // // /** // * Let custom exporters to filter logs // * // * @param log // * @return true if given log request should be skipped // */ // public boolean skipLog(RequestLogs log); // // /** // * This method allows you to customize which application versions logs you // * want exported. The logs API requires us to specify a list of application // * versions. This corresponds to the "major" version. See the logs api docs // * // * @return a list of "major" application versions or null if you want to just // * export logs for the application this task is currently running on // */ // public List<String> applicationVersionsToExport(); // // /** // * Get prefix value for this ExporterSet // * @return Prefix name of this exporterset // */ // public String getPrefix(); // // } // Path: src/main/java/com/l2bq/logging/analysis/exporter/applog/signup/SignupExporterSet.java import java.util.Arrays; import java.util.List; import com.google.appengine.api.log.RequestLogs; import com.l2bq.logging.analysis.BigqueryFieldExporter; import com.l2bq.logging.analysis.BigqueryFieldExporterSet; package com.l2bq.logging.analysis.exporter.applog.signup; public class SignupExporterSet implements BigqueryFieldExporterSet { @Override
public List<BigqueryFieldExporter> getExporters() {
gocd/go-plugins
plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/model/GitConfig.java
// Path: plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/util/StringUtil.java // public class StringUtil { // public static boolean isEmpty(String str) { // return str == null || str.trim().isEmpty(); // } // }
import com.tw.go.scm.plugin.util.StringUtil;
package com.tw.go.scm.plugin.model; public class GitConfig { private String url; private String username; private String password; private String branch; private boolean subModule = false; private boolean recursiveSubModuleUpdate = true; private boolean shallowClone = false; public GitConfig(String url) { this.url = url; } public GitConfig(String url, String username, String password, String branch) { this(url, username, password, branch, true, false); } public GitConfig(String url, String username, String password, String branch, boolean recursiveSubModuleUpdate, boolean shallowClone) { this.url = url; this.username = username; this.password = password; this.branch = branch; this.recursiveSubModuleUpdate = recursiveSubModuleUpdate; this.shallowClone = shallowClone; } public boolean isRemoteUrl() { return url.startsWith("http://") || url.startsWith("https://"); } public boolean hasCredentials() {
// Path: plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/util/StringUtil.java // public class StringUtil { // public static boolean isEmpty(String str) { // return str == null || str.trim().isEmpty(); // } // } // Path: plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/model/GitConfig.java import com.tw.go.scm.plugin.util.StringUtil; package com.tw.go.scm.plugin.model; public class GitConfig { private String url; private String username; private String password; private String branch; private boolean subModule = false; private boolean recursiveSubModuleUpdate = true; private boolean shallowClone = false; public GitConfig(String url) { this.url = url; } public GitConfig(String url, String username, String password, String branch) { this(url, username, password, branch, true, false); } public GitConfig(String url, String username, String password, String branch, boolean recursiveSubModuleUpdate, boolean shallowClone) { this.url = url; this.username = username; this.password = password; this.branch = branch; this.recursiveSubModuleUpdate = recursiveSubModuleUpdate; this.shallowClone = shallowClone; } public boolean isRemoteUrl() { return url.startsWith("http://") || url.startsWith("https://"); } public boolean hasCredentials() {
return !StringUtil.isEmpty(url) && !StringUtil.isEmpty(password);
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactPlan.java // public class ArtifactPlan { // private String id; // private String storeId; // @SerializedName("configuration") // private ArtifactConfig artifactConfig; // // public String getId() { // return id; // } // // public String getStoreId() { // return storeId; // } // // public ArtifactConfig getArtifactConfig() { // return artifactConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStore.java // public class ArtifactStore { // private String id; // @SerializedName("configuration") // private ArtifactStoreConfig artifactStoreConfig; // // public String getId() { // return id; // } // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/JobIdentifier.java // public class JobIdentifier { // private String pipeline; // private String pipelineCounter; // private String stage; // private String stageCounter; // private String job; // // public JobIdentifier() { // } // // public JobIdentifier(Map<String, String> environmentVariables) { // pipeline = environmentVariables.get("GO_PIPELINE_NAME"); // pipelineCounter = environmentVariables.get("GO_PIPELINE_COUNTER"); // stage = environmentVariables.get("GO_STAGE_NAME"); // stageCounter = environmentVariables.get("GO_STAGE_COUNTER"); // job = environmentVariables.get("GO_JOB_NAME"); // } // // public String getPipeline() { // return pipeline; // } // // public String getPipelineCounter() { // return pipelineCounter; // } // // public String getStage() { // return stage; // } // // public String getStageCounter() { // return stageCounter; // } // // public String getJob() { // return job; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.model.ArtifactPlan; import cd.go.artifact.dummy.model.ArtifactStore; import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.JobIdentifier; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class PublishArtifactRequest { @Expose @SerializedName("agent_working_directory") private String agentWorkingDir; @Expose @SerializedName("artifact_store")
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactPlan.java // public class ArtifactPlan { // private String id; // private String storeId; // @SerializedName("configuration") // private ArtifactConfig artifactConfig; // // public String getId() { // return id; // } // // public String getStoreId() { // return storeId; // } // // public ArtifactConfig getArtifactConfig() { // return artifactConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStore.java // public class ArtifactStore { // private String id; // @SerializedName("configuration") // private ArtifactStoreConfig artifactStoreConfig; // // public String getId() { // return id; // } // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/JobIdentifier.java // public class JobIdentifier { // private String pipeline; // private String pipelineCounter; // private String stage; // private String stageCounter; // private String job; // // public JobIdentifier() { // } // // public JobIdentifier(Map<String, String> environmentVariables) { // pipeline = environmentVariables.get("GO_PIPELINE_NAME"); // pipelineCounter = environmentVariables.get("GO_PIPELINE_COUNTER"); // stage = environmentVariables.get("GO_STAGE_NAME"); // stageCounter = environmentVariables.get("GO_STAGE_COUNTER"); // job = environmentVariables.get("GO_JOB_NAME"); // } // // public String getPipeline() { // return pipeline; // } // // public String getPipelineCounter() { // return pipelineCounter; // } // // public String getStage() { // return stage; // } // // public String getStageCounter() { // return stageCounter; // } // // public String getJob() { // return job; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java import cd.go.artifact.dummy.model.ArtifactPlan; import cd.go.artifact.dummy.model.ArtifactStore; import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.JobIdentifier; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class PublishArtifactRequest { @Expose @SerializedName("agent_working_directory") private String agentWorkingDir; @Expose @SerializedName("artifact_store")
private ArtifactStore artifactStore;
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactPlan.java // public class ArtifactPlan { // private String id; // private String storeId; // @SerializedName("configuration") // private ArtifactConfig artifactConfig; // // public String getId() { // return id; // } // // public String getStoreId() { // return storeId; // } // // public ArtifactConfig getArtifactConfig() { // return artifactConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStore.java // public class ArtifactStore { // private String id; // @SerializedName("configuration") // private ArtifactStoreConfig artifactStoreConfig; // // public String getId() { // return id; // } // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/JobIdentifier.java // public class JobIdentifier { // private String pipeline; // private String pipelineCounter; // private String stage; // private String stageCounter; // private String job; // // public JobIdentifier() { // } // // public JobIdentifier(Map<String, String> environmentVariables) { // pipeline = environmentVariables.get("GO_PIPELINE_NAME"); // pipelineCounter = environmentVariables.get("GO_PIPELINE_COUNTER"); // stage = environmentVariables.get("GO_STAGE_NAME"); // stageCounter = environmentVariables.get("GO_STAGE_COUNTER"); // job = environmentVariables.get("GO_JOB_NAME"); // } // // public String getPipeline() { // return pipeline; // } // // public String getPipelineCounter() { // return pipelineCounter; // } // // public String getStage() { // return stage; // } // // public String getStageCounter() { // return stageCounter; // } // // public String getJob() { // return job; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.model.ArtifactPlan; import cd.go.artifact.dummy.model.ArtifactStore; import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.JobIdentifier; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class PublishArtifactRequest { @Expose @SerializedName("agent_working_directory") private String agentWorkingDir; @Expose @SerializedName("artifact_store") private ArtifactStore artifactStore; @Expose @SerializedName("artifact_plan")
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactPlan.java // public class ArtifactPlan { // private String id; // private String storeId; // @SerializedName("configuration") // private ArtifactConfig artifactConfig; // // public String getId() { // return id; // } // // public String getStoreId() { // return storeId; // } // // public ArtifactConfig getArtifactConfig() { // return artifactConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStore.java // public class ArtifactStore { // private String id; // @SerializedName("configuration") // private ArtifactStoreConfig artifactStoreConfig; // // public String getId() { // return id; // } // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/JobIdentifier.java // public class JobIdentifier { // private String pipeline; // private String pipelineCounter; // private String stage; // private String stageCounter; // private String job; // // public JobIdentifier() { // } // // public JobIdentifier(Map<String, String> environmentVariables) { // pipeline = environmentVariables.get("GO_PIPELINE_NAME"); // pipelineCounter = environmentVariables.get("GO_PIPELINE_COUNTER"); // stage = environmentVariables.get("GO_STAGE_NAME"); // stageCounter = environmentVariables.get("GO_STAGE_COUNTER"); // job = environmentVariables.get("GO_JOB_NAME"); // } // // public String getPipeline() { // return pipeline; // } // // public String getPipelineCounter() { // return pipelineCounter; // } // // public String getStage() { // return stage; // } // // public String getStageCounter() { // return stageCounter; // } // // public String getJob() { // return job; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java import cd.go.artifact.dummy.model.ArtifactPlan; import cd.go.artifact.dummy.model.ArtifactStore; import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.JobIdentifier; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class PublishArtifactRequest { @Expose @SerializedName("agent_working_directory") private String agentWorkingDir; @Expose @SerializedName("artifact_store") private ArtifactStore artifactStore; @Expose @SerializedName("artifact_plan")
private ArtifactPlan artifactPlan;
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactPlan.java // public class ArtifactPlan { // private String id; // private String storeId; // @SerializedName("configuration") // private ArtifactConfig artifactConfig; // // public String getId() { // return id; // } // // public String getStoreId() { // return storeId; // } // // public ArtifactConfig getArtifactConfig() { // return artifactConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStore.java // public class ArtifactStore { // private String id; // @SerializedName("configuration") // private ArtifactStoreConfig artifactStoreConfig; // // public String getId() { // return id; // } // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/JobIdentifier.java // public class JobIdentifier { // private String pipeline; // private String pipelineCounter; // private String stage; // private String stageCounter; // private String job; // // public JobIdentifier() { // } // // public JobIdentifier(Map<String, String> environmentVariables) { // pipeline = environmentVariables.get("GO_PIPELINE_NAME"); // pipelineCounter = environmentVariables.get("GO_PIPELINE_COUNTER"); // stage = environmentVariables.get("GO_STAGE_NAME"); // stageCounter = environmentVariables.get("GO_STAGE_COUNTER"); // job = environmentVariables.get("GO_JOB_NAME"); // } // // public String getPipeline() { // return pipeline; // } // // public String getPipelineCounter() { // return pipelineCounter; // } // // public String getStage() { // return stage; // } // // public String getStageCounter() { // return stageCounter; // } // // public String getJob() { // return job; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.model.ArtifactPlan; import cd.go.artifact.dummy.model.ArtifactStore; import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.JobIdentifier; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
public static PublishArtifactRequest fromJSON(String json) { return GSON.fromJson(json, PublishArtifactRequest.class); } public String toJSON() { return GSON.toJson(this); } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof PublishArtifactRequest)) return false; PublishArtifactRequest that = (PublishArtifactRequest) o; if (agentWorkingDir != null ? !agentWorkingDir.equals(that.agentWorkingDir) : that.agentWorkingDir != null) return false; if (artifactStore != null ? !artifactStore.equals(that.artifactStore) : that.artifactStore != null) return false; return artifactPlan != null ? artifactPlan.equals(that.artifactPlan) : that.artifactPlan == null; } @Override public int hashCode() { int result = agentWorkingDir != null ? agentWorkingDir.hashCode() : 0; result = 31 * result + (artifactStore != null ? artifactStore.hashCode() : 0); result = 31 * result + (artifactPlan != null ? artifactPlan.hashCode() : 0); return result; }
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactPlan.java // public class ArtifactPlan { // private String id; // private String storeId; // @SerializedName("configuration") // private ArtifactConfig artifactConfig; // // public String getId() { // return id; // } // // public String getStoreId() { // return storeId; // } // // public ArtifactConfig getArtifactConfig() { // return artifactConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStore.java // public class ArtifactStore { // private String id; // @SerializedName("configuration") // private ArtifactStoreConfig artifactStoreConfig; // // public String getId() { // return id; // } // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/JobIdentifier.java // public class JobIdentifier { // private String pipeline; // private String pipelineCounter; // private String stage; // private String stageCounter; // private String job; // // public JobIdentifier() { // } // // public JobIdentifier(Map<String, String> environmentVariables) { // pipeline = environmentVariables.get("GO_PIPELINE_NAME"); // pipelineCounter = environmentVariables.get("GO_PIPELINE_COUNTER"); // stage = environmentVariables.get("GO_STAGE_NAME"); // stageCounter = environmentVariables.get("GO_STAGE_COUNTER"); // job = environmentVariables.get("GO_JOB_NAME"); // } // // public String getPipeline() { // return pipeline; // } // // public String getPipelineCounter() { // return pipelineCounter; // } // // public String getStage() { // return stage; // } // // public String getStageCounter() { // return stageCounter; // } // // public String getJob() { // return job; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java import cd.go.artifact.dummy.model.ArtifactPlan; import cd.go.artifact.dummy.model.ArtifactStore; import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.JobIdentifier; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; public static PublishArtifactRequest fromJSON(String json) { return GSON.fromJson(json, PublishArtifactRequest.class); } public String toJSON() { return GSON.toJson(this); } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof PublishArtifactRequest)) return false; PublishArtifactRequest that = (PublishArtifactRequest) o; if (agentWorkingDir != null ? !agentWorkingDir.equals(that.agentWorkingDir) : that.agentWorkingDir != null) return false; if (artifactStore != null ? !artifactStore.equals(that.artifactStore) : that.artifactStore != null) return false; return artifactPlan != null ? artifactPlan.equals(that.artifactPlan) : that.artifactPlan == null; } @Override public int hashCode() { int result = agentWorkingDir != null ? agentWorkingDir.hashCode() : 0; result = 31 * result + (artifactStore != null ? artifactStore.hashCode() : 0); result = 31 * result + (artifactPlan != null ? artifactPlan.hashCode() : 0); return result; }
public JobIdentifier getJobIdentifier() {
gocd/go-plugins
plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/model/Revision.java
// Path: plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/util/ListUtil.java // public class ListUtil { // public static boolean isEmpty(List list) { // return list == null || list.isEmpty(); // } // // public static String join(Collection c) { // return join(c, ", "); // } // // public static String join(Collection c, String join) { // StringBuffer sb = new StringBuffer(); // for (Iterator<Object> iter = c.iterator(); iter.hasNext(); ) { // sb.append(iter.next()); // if (iter.hasNext()) { // sb.append(join); // } // } // return sb.toString(); // } // // public static String[] toArray(List<String> args) { // return args.toArray(new String[args.size()]); // } // }
import com.tw.go.scm.plugin.util.ListUtil; import java.util.ArrayList; import java.util.Date; import java.util.List;
public void setComment(String comment) { this.comment = comment; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getEmailId() { return emailId; } public void setEmailId(String emailId) { this.emailId = emailId; } public List<ModifiedFile> getModifiedFiles() { return modifiedFiles; } public void setModifiedFiles(List<ModifiedFile> modifiedFiles) { this.modifiedFiles = modifiedFiles; } public final ModifiedFile createModifiedFile(String filename, String action) { ModifiedFile file = new ModifiedFile(filename, action);
// Path: plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/util/ListUtil.java // public class ListUtil { // public static boolean isEmpty(List list) { // return list == null || list.isEmpty(); // } // // public static String join(Collection c) { // return join(c, ", "); // } // // public static String join(Collection c, String join) { // StringBuffer sb = new StringBuffer(); // for (Iterator<Object> iter = c.iterator(); iter.hasNext(); ) { // sb.append(iter.next()); // if (iter.hasNext()) { // sb.append(join); // } // } // return sb.toString(); // } // // public static String[] toArray(List<String> args) { // return args.toArray(new String[args.size()]); // } // } // Path: plugins-for-tests/test-scm-plugin/src/main/java/com/tw/go/scm/plugin/model/Revision.java import com.tw.go.scm.plugin.util.ListUtil; import java.util.ArrayList; import java.util.Date; import java.util.List; public void setComment(String comment) { this.comment = comment; } public String getUser() { return user; } public void setUser(String user) { this.user = user; } public String getEmailId() { return emailId; } public void setEmailId(String emailId) { this.emailId = emailId; } public List<ModifiedFile> getModifiedFiles() { return modifiedFiles; } public void setModifiedFiles(List<ModifiedFile> modifiedFiles) { this.modifiedFiles = modifiedFiles; } public final ModifiedFile createModifiedFile(String filename, String action) { ModifiedFile file = new ModifiedFile(filename, action);
if (ListUtil.isEmpty(modifiedFiles)) {
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactConfig.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactConfig)) return false; ArtifactConfig that = (ArtifactConfig) o; return source != null ? source.equals(that.source) : that.source == null; } @Override public int hashCode() { return source != null ? source.hashCode() : 0; } public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (StringUtils.isBlank(source)) { result.addError("Source", "must be provided."); } if (StringUtils.isBlank(destination)) { result.addError("Destination", "must be provided."); } return result; } public static ArtifactConfig from(String json) {
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactConfig.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactConfig)) return false; ArtifactConfig that = (ArtifactConfig) o; return source != null ? source.equals(that.source) : that.source == null; } @Override public int hashCode() { return source != null ? source.hashCode() : 0; } public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (StringUtils.isBlank(source)) { result.addError("Source", "must be provided."); } if (StringUtils.isBlank(destination)) { result.addError("Destination", "must be provided."); } return result; } public static ArtifactConfig from(String json) {
return GSON.fromJson(json, ArtifactConfig.class);
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactConfig.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
ArtifactConfig that = (ArtifactConfig) o; return source != null ? source.equals(that.source) : that.source == null; } @Override public int hashCode() { return source != null ? source.hashCode() : 0; } public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (StringUtils.isBlank(source)) { result.addError("Source", "must be provided."); } if (StringUtils.isBlank(destination)) { result.addError("Destination", "must be provided."); } return result; } public static ArtifactConfig from(String json) { return GSON.fromJson(json, ArtifactConfig.class); } public static String artifactConfigMetadata() { return GSON.toJson(Arrays.asList(
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactConfig.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; ArtifactConfig that = (ArtifactConfig) o; return source != null ? source.equals(that.source) : that.source == null; } @Override public int hashCode() { return source != null ? source.hashCode() : 0; } public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (StringUtils.isBlank(source)) { result.addError("Source", "must be provided."); } if (StringUtils.isBlank(destination)) { result.addError("Destination", "must be provided."); } return result; } public static ArtifactConfig from(String json) { return GSON.fromJson(json, ArtifactConfig.class); } public static String artifactConfigMetadata() { return GSON.toJson(Arrays.asList(
new Field("Source", new Metadata(true, false)),
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactConfig.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
ArtifactConfig that = (ArtifactConfig) o; return source != null ? source.equals(that.source) : that.source == null; } @Override public int hashCode() { return source != null ? source.hashCode() : 0; } public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (StringUtils.isBlank(source)) { result.addError("Source", "must be provided."); } if (StringUtils.isBlank(destination)) { result.addError("Destination", "must be provided."); } return result; } public static ArtifactConfig from(String json) { return GSON.fromJson(json, ArtifactConfig.class); } public static String artifactConfigMetadata() { return GSON.toJson(Arrays.asList(
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactConfig.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; ArtifactConfig that = (ArtifactConfig) o; return source != null ? source.equals(that.source) : that.source == null; } @Override public int hashCode() { return source != null ? source.hashCode() : 0; } public ValidationResult validate() { ValidationResult result = new ValidationResult(); if (StringUtils.isBlank(source)) { result.addError("Source", "must be provided."); } if (StringUtils.isBlank(destination)) { result.addError("Destination", "must be provided."); } return result; } public static ArtifactConfig from(String json) { return GSON.fromJson(json, ArtifactConfig.class); } public static String artifactConfigMetadata() { return GSON.toJson(Arrays.asList(
new Field("Source", new Metadata(true, false)),
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class FetchArtifact { @SerializedName("Path") private String path; public String getPath() { return path; } public static String metadata() {
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class FetchArtifact { @SerializedName("Path") private String path; public String getPath() { return path; } public static String metadata() {
return GSON.toJson(Arrays.asList(
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class FetchArtifact { @SerializedName("Path") private String path; public String getPath() { return path; } public static String metadata() { return GSON.toJson(Arrays.asList(
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class FetchArtifact { @SerializedName("Path") private String path; public String getPath() { return path; } public static String metadata() { return GSON.toJson(Arrays.asList(
new Field("Path",new Metadata(true,false))
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class FetchArtifact { @SerializedName("Path") private String path; public String getPath() { return path; } public static String metadata() { return GSON.toJson(Arrays.asList(
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class FetchArtifact { @SerializedName("Path") private String path; public String getPath() { return path; } public static String metadata() { return GSON.toJson(Arrays.asList(
new Field("Path",new Metadata(true,false))
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ValidationResult.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import java.util.Collection; import java.util.HashSet; import java.util.Set; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class ValidationResult { private final Set<ValidationError> errors = new HashSet<>(); public ValidationResult() { } public ValidationResult(Collection<ValidationError> errors) { this.errors.addAll(errors); } public void addError(String key, String message) { errors.add(new ValidationError(key, message)); } public void addError(ValidationError validationError) { if (validationError == null) { return; } errors.add(validationError); } public boolean hasErrors() { return !errors.isEmpty(); } public String toJSON() {
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ValidationResult.java import java.util.Collection; import java.util.HashSet; import java.util.Set; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.model; public class ValidationResult { private final Set<ValidationError> errors = new HashSet<>(); public ValidationResult() { } public ValidationResult(Collection<ValidationError> errors) { this.errors.addAll(errors); } public void addError(String key, String message) { errors.add(new ValidationError(key, message)); } public void addError(ValidationError validationError) { if (validationError == null) { return; } errors.add(validationError); } public boolean hasErrors() { return !errors.isEmpty(); } public String toJSON() {
return GSON.toJson(errors);
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/test/java/cd/go/artifact/dummy/DummyArtifactPluginTest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import static org.mockito.Mockito.when; import com.google.gson.Gson; import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException; import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse; import org.json.JSONException; import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import java.util.Collections; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock;
} @Test void shouldReturnArtifactStoreMetadata() throws UnhandledRequestTypeException { final String expectedMetadata = "[{\"key\":\"Url\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"Username\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"Password\",\"metadata\":{\"required\":true,\"secure\":true}}]"; final GoPluginApiRequest request = mock(GoPluginApiRequest.class); when(request.requestName()).thenReturn(RequestFromServer.REQUEST_STORE_CONFIG_METADATA.getRequestName()); final GoPluginApiResponse response = new DummyArtifactPlugin().handle(request); assertThat(response.responseCode()).isEqualTo(200); assertThat(response.responseBody()).isEqualTo(expectedMetadata); } @Test void shouldReturnArtifactStoreView() throws UnhandledRequestTypeException { final GoPluginApiRequest request = mock(GoPluginApiRequest.class); when(request.requestName()).thenReturn(RequestFromServer.REQUEST_STORE_CONFIG_VIEW.getRequestName()); final GoPluginApiResponse response = new DummyArtifactPlugin().handle(request); final Map<String, String> expectedTemplate = Collections.singletonMap("template", ResourceReader.read("/artifact-store.template.html")); assertThat(response.responseCode()).isEqualTo(200); assertThat(response.responseBody()).isEqualTo(new Gson().toJson(expectedTemplate)); } @Test void shouldValidateArtifactStoreConfig() throws UnhandledRequestTypeException, JSONException { final GoPluginApiRequest request = mock(GoPluginApiRequest.class); when(request.requestName()).thenReturn(RequestFromServer.REQUEST_STORE_CONFIG_VALIDATE.getRequestName());
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/test/java/cd/go/artifact/dummy/DummyArtifactPluginTest.java import static org.mockito.Mockito.when; import com.google.gson.Gson; import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException; import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse; import org.json.JSONException; import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import java.util.Collections; import java.util.Map; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; } @Test void shouldReturnArtifactStoreMetadata() throws UnhandledRequestTypeException { final String expectedMetadata = "[{\"key\":\"Url\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"Username\",\"metadata\":{\"required\":true,\"secure\":false}},{\"key\":\"Password\",\"metadata\":{\"required\":true,\"secure\":true}}]"; final GoPluginApiRequest request = mock(GoPluginApiRequest.class); when(request.requestName()).thenReturn(RequestFromServer.REQUEST_STORE_CONFIG_METADATA.getRequestName()); final GoPluginApiResponse response = new DummyArtifactPlugin().handle(request); assertThat(response.responseCode()).isEqualTo(200); assertThat(response.responseBody()).isEqualTo(expectedMetadata); } @Test void shouldReturnArtifactStoreView() throws UnhandledRequestTypeException { final GoPluginApiRequest request = mock(GoPluginApiRequest.class); when(request.requestName()).thenReturn(RequestFromServer.REQUEST_STORE_CONFIG_VIEW.getRequestName()); final GoPluginApiResponse response = new DummyArtifactPlugin().handle(request); final Map<String, String> expectedTemplate = Collections.singletonMap("template", ResourceReader.read("/artifact-store.template.html")); assertThat(response.responseCode()).isEqualTo(200); assertThat(response.responseBody()).isEqualTo(new Gson().toJson(expectedTemplate)); } @Test void shouldValidateArtifactStoreConfig() throws UnhandledRequestTypeException, JSONException { final GoPluginApiRequest request = mock(GoPluginApiRequest.class); when(request.requestName()).thenReturn(RequestFromServer.REQUEST_STORE_CONFIG_VALIDATE.getRequestName());
when(request.requestBody()).thenReturn(GSON.toJson(Collections.singletonMap("Url", "httpd://foo/bar")));
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
} if (StringUtils.isBlank(password)) { result.addError("Password", "must be provided."); } return result; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactStoreConfig)) return false; ArtifactStoreConfig that = (ArtifactStoreConfig) o; if (url != null ? !url.equals(that.url) : that.url != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; return password != null ? password.equals(that.password) : that.password == null; } @Override public int hashCode() { int result = url != null ? url.hashCode() : 0; result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (password != null ? password.hashCode() : 0); return result; } public static ArtifactStoreConfig from(String json) {
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; } if (StringUtils.isBlank(password)) { result.addError("Password", "must be provided."); } return result; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactStoreConfig)) return false; ArtifactStoreConfig that = (ArtifactStoreConfig) o; if (url != null ? !url.equals(that.url) : that.url != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; return password != null ? password.equals(that.password) : that.password == null; } @Override public int hashCode() { int result = url != null ? url.hashCode() : 0; result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (password != null ? password.hashCode() : 0); return result; } public static ArtifactStoreConfig from(String json) {
return GSON.fromJson(json, ArtifactStoreConfig.class);
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
return result; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactStoreConfig)) return false; ArtifactStoreConfig that = (ArtifactStoreConfig) o; if (url != null ? !url.equals(that.url) : that.url != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; return password != null ? password.equals(that.password) : that.password == null; } @Override public int hashCode() { int result = url != null ? url.hashCode() : 0; result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (password != null ? password.hashCode() : 0); return result; } public static ArtifactStoreConfig from(String json) { return GSON.fromJson(json, ArtifactStoreConfig.class); } public static String artifactStoreMetadata() { return GSON.toJson(Arrays.asList(
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; return result; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactStoreConfig)) return false; ArtifactStoreConfig that = (ArtifactStoreConfig) o; if (url != null ? !url.equals(that.url) : that.url != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; return password != null ? password.equals(that.password) : that.password == null; } @Override public int hashCode() { int result = url != null ? url.hashCode() : 0; result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (password != null ? password.hashCode() : 0); return result; } public static ArtifactStoreConfig from(String json) { return GSON.fromJson(json, ArtifactStoreConfig.class); } public static String artifactStoreMetadata() { return GSON.toJson(Arrays.asList(
new Field("Url", new Metadata(true, false)),
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
return result; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactStoreConfig)) return false; ArtifactStoreConfig that = (ArtifactStoreConfig) o; if (url != null ? !url.equals(that.url) : that.url != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; return password != null ? password.equals(that.password) : that.password == null; } @Override public int hashCode() { int result = url != null ? url.hashCode() : 0; result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (password != null ? password.hashCode() : 0); return result; } public static ArtifactStoreConfig from(String json) { return GSON.fromJson(json, ArtifactStoreConfig.class); } public static String artifactStoreMetadata() { return GSON.toJson(Arrays.asList(
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Field.java // public class Field { // private String key; // private Metadata metadata; // // public Field(String key, Metadata metadata) { // this.key = key; // this.metadata = metadata; // } // // public String getKey() { // return key; // } // // public Metadata getMetadata() { // return metadata; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/config/Metadata.java // public class Metadata { // private boolean required; // private boolean secure; // // public Metadata(boolean required, boolean secure) { // this.required = required; // this.secure = secure; // } // // public boolean isRequired() { // return required; // } // // public boolean isSecure() { // return secure; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java import cd.go.artifact.dummy.config.Field; import cd.go.artifact.dummy.config.Metadata; import com.google.gson.annotations.SerializedName; import org.apache.commons.lang3.StringUtils; import java.util.Arrays; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; return result; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ArtifactStoreConfig)) return false; ArtifactStoreConfig that = (ArtifactStoreConfig) o; if (url != null ? !url.equals(that.url) : that.url != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; return password != null ? password.equals(that.password) : that.password == null; } @Override public int hashCode() { int result = url != null ? url.hashCode() : 0; result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (password != null ? password.hashCode() : 0); return result; } public static ArtifactStoreConfig from(String json) { return GSON.fromJson(json, ArtifactStoreConfig.class); } public static String artifactStoreMetadata() { return GSON.toJson(Arrays.asList(
new Field("Url", new Metadata(true, false)),
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/View.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/ResourceReader.java // public static String read(String resourceFile) { // return new String(readBytes(resourceFile), StandardCharsets.UTF_8); // }
import java.util.Collections; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; import static cd.go.artifact.dummy.ResourceReader.read;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy; public class View { private String viewPath; public View(String viewPath) { this.viewPath = viewPath; } public String toJSON() {
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/ResourceReader.java // public static String read(String resourceFile) { // return new String(readBytes(resourceFile), StandardCharsets.UTF_8); // } // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/View.java import java.util.Collections; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; import static cd.go.artifact.dummy.ResourceReader.read; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy; public class View { private String viewPath; public View(String viewPath) { this.viewPath = viewPath; } public String toJSON() {
return GSON.toJson(Collections.singletonMap("template", read(viewPath)));
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/View.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/ResourceReader.java // public static String read(String resourceFile) { // return new String(readBytes(resourceFile), StandardCharsets.UTF_8); // }
import java.util.Collections; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; import static cd.go.artifact.dummy.ResourceReader.read;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy; public class View { private String viewPath; public View(String viewPath) { this.viewPath = viewPath; } public String toJSON() {
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/ResourceReader.java // public static String read(String resourceFile) { // return new String(readBytes(resourceFile), StandardCharsets.UTF_8); // } // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/View.java import java.util.Collections; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; import static cd.go.artifact.dummy.ResourceReader.read; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy; public class View { private String viewPath; public View(String viewPath) { this.viewPath = viewPath; } public String toJSON() {
return GSON.toJson(Collections.singletonMap("template", read(viewPath)));
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration")
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration")
private ArtifactStoreConfig artifactStoreConfig;
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration") private ArtifactStoreConfig artifactStoreConfig; @Expose @SerializedName("fetch_artifact_configuration")
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration") private ArtifactStoreConfig artifactStoreConfig; @Expose @SerializedName("fetch_artifact_configuration")
private FetchArtifact fetchArtifact;
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration") private ArtifactStoreConfig artifactStoreConfig; @Expose @SerializedName("fetch_artifact_configuration") private FetchArtifact fetchArtifact; @Expose @SerializedName("artifact_metadata")
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration") private ArtifactStoreConfig artifactStoreConfig; @Expose @SerializedName("fetch_artifact_configuration") private FetchArtifact fetchArtifact; @Expose @SerializedName("artifact_metadata")
private PublishMetadata metadata;
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson();
import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration") private ArtifactStoreConfig artifactStoreConfig; @Expose @SerializedName("fetch_artifact_configuration") private FetchArtifact fetchArtifact; @Expose @SerializedName("artifact_metadata") private PublishMetadata metadata; public ArtifactStoreConfig getArtifactStoreConfig() { return artifactStoreConfig; } public PublishMetadata getMetadata() { return metadata; } public static FetchArtifactRequest fromJSON(String json) {
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public class ArtifactStoreConfig { // @SerializedName("Url") // private String url; // @SerializedName("Username") // private String username; // @SerializedName("Password") // private String password; // // public String getUrl() { // return url; // } // // public String getUsername() { // return username; // } // // public String getPassword() { // return password; // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(url)) { // result.addError("Url", "must be provided."); // } // // if (StringUtils.isBlank(username)) { // result.addError("Username", "must be provided."); // } // // if (StringUtils.isBlank(password)) { // result.addError("Password", "must be provided."); // } // // return result; // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof ArtifactStoreConfig)) return false; // // ArtifactStoreConfig that = (ArtifactStoreConfig) o; // // if (url != null ? !url.equals(that.url) : that.url != null) return false; // if (username != null ? !username.equals(that.username) : that.username != null) return false; // return password != null ? password.equals(that.password) : that.password == null; // } // // @Override // public int hashCode() { // int result = url != null ? url.hashCode() : 0; // result = 31 * result + (username != null ? username.hashCode() : 0); // result = 31 * result + (password != null ? password.hashCode() : 0); // return result; // } // // public static ArtifactStoreConfig from(String json) { // return GSON.fromJson(json, ArtifactStoreConfig.class); // } // // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/FetchArtifact.java // public class FetchArtifact { // @SerializedName("Path") // private String path; // // public String getPath() { // return path; // } // // public static String metadata() { // return GSON.toJson(Arrays.asList( // new Field("Path",new Metadata(true,false)) // )); // } // // public static FetchArtifact from(String json) { // return GSON.fromJson(json, FetchArtifact.class); // } // // public ValidationResult validate() { // ValidationResult result = new ValidationResult(); // if (StringUtils.isBlank(path)) { // result.addError("Path", "must be provided."); // } // return result; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/PublishMetadata.java // public class PublishMetadata { // @SerializedName("filename") // private String filename; // @SerializedName("jobIdentifier") // private JobIdentifier jobIdentifier; // // public PublishMetadata() { // } // // public PublishMetadata(String filename, JobIdentifier jobIdentifier) { // this.filename = filename; // this.jobIdentifier = jobIdentifier; // } // // // public JobIdentifier getJobIdentifier() { // return jobIdentifier; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java // public static final Gson GSON = new Gson(); // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java import cd.go.artifact.dummy.model.ArtifactStoreConfig; import cd.go.artifact.dummy.model.FetchArtifact; import cd.go.artifact.dummy.model.PublishMetadata; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; import static cd.go.artifact.dummy.DummyArtifactPlugin.GSON; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy.request; public class FetchArtifactRequest { @Expose @SerializedName("store_configuration") private ArtifactStoreConfig artifactStoreConfig; @Expose @SerializedName("fetch_artifact_configuration") private FetchArtifact fetchArtifact; @Expose @SerializedName("artifact_metadata") private PublishMetadata metadata; public ArtifactStoreConfig getArtifactStoreConfig() { return artifactStoreConfig; } public PublishMetadata getMetadata() { return metadata; } public static FetchArtifactRequest fromJSON(String json) {
return GSON.fromJson(json, FetchArtifactRequest.class);
gocd/go-plugins
plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java // public class FetchArtifactRequest { // @Expose // @SerializedName("store_configuration") // private ArtifactStoreConfig artifactStoreConfig; // @Expose // @SerializedName("fetch_artifact_configuration") // private FetchArtifact fetchArtifact; // @Expose // @SerializedName("artifact_metadata") // private PublishMetadata metadata; // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // // public PublishMetadata getMetadata() { // return metadata; // } // // public static FetchArtifactRequest fromJSON(String json) { // return GSON.fromJson(json, FetchArtifactRequest.class); // } // // public FetchArtifact getFetchArtifact() { // return fetchArtifact; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java // public class PublishArtifactRequest { // @Expose // @SerializedName("agent_working_directory") // private String agentWorkingDir; // // @Expose // @SerializedName("artifact_store") // private ArtifactStore artifactStore; // // @Expose // @SerializedName("artifact_plan") // private ArtifactPlan artifactPlan; // // @Expose // @SerializedName("environment_variables") // private Map<String, String> environmentVariables; // private Object jobIdentifier; // // public PublishArtifactRequest() { // } // // public String getAgentWorkingDir() { // return agentWorkingDir; // } // // public ArtifactStore getArtifactStore() { // return artifactStore; // } // // public ArtifactPlan getArtifactPlan() { // return artifactPlan; // } // // public Map<String, String> getEnvironmentVariables() { // return environmentVariables; // } // // public static PublishArtifactRequest fromJSON(String json) { // return GSON.fromJson(json, PublishArtifactRequest.class); // } // // public String toJSON() { // return GSON.toJson(this); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof PublishArtifactRequest)) return false; // // PublishArtifactRequest that = (PublishArtifactRequest) o; // // if (agentWorkingDir != null ? !agentWorkingDir.equals(that.agentWorkingDir) : that.agentWorkingDir != null) // return false; // if (artifactStore != null ? !artifactStore.equals(that.artifactStore) : that.artifactStore != null) // return false; // return artifactPlan != null ? artifactPlan.equals(that.artifactPlan) : that.artifactPlan == null; // } // // @Override // public int hashCode() { // int result = agentWorkingDir != null ? agentWorkingDir.hashCode() : 0; // result = 31 * result + (artifactStore != null ? artifactStore.hashCode() : 0); // result = 31 * result + (artifactPlan != null ? artifactPlan.hashCode() : 0); // return result; // } // // public JobIdentifier getJobIdentifier() { // return new JobIdentifier(getEnvironmentVariables()); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // }
import cd.go.artifact.dummy.model.*; import cd.go.artifact.dummy.request.FetchArtifactRequest; import cd.go.artifact.dummy.request.PublishArtifactRequest; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.thoughtworks.go.plugin.api.GoApplicationAccessor; import com.thoughtworks.go.plugin.api.GoPlugin; import com.thoughtworks.go.plugin.api.GoPluginIdentifier; import com.thoughtworks.go.plugin.api.annotation.Extension; import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException; import com.thoughtworks.go.plugin.api.logging.Logger; import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse; import okhttp3.*; import java.io.File; import java.io.IOException; import java.util.Base64; import static cd.go.artifact.dummy.model.ArtifactStoreConfig.artifactStoreMetadata; import static java.lang.String.format; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap;
/* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy; @Extension public class DummyArtifactPlugin implements GoPlugin { public static final Gson GSON = new Gson(); public static final Logger LOG = Logger.getLoggerFor(DummyArtifactPlugin.class); public static final OkHttpClient CLIENT = new OkHttpClient(); @Override public void initializeGoApplicationAccessor(GoApplicationAccessor goApplicationAccessor) { } @Override public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException { final RequestFromServer requestFromServer = RequestFromServer.from(request.requestName()); try { switch (requestFromServer) { case REQUEST_GET_CAPABILITIES: return DefaultGoPluginApiResponse.success("{}"); case REQUEST_STORE_CONFIG_METADATA:
// Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/FetchArtifactRequest.java // public class FetchArtifactRequest { // @Expose // @SerializedName("store_configuration") // private ArtifactStoreConfig artifactStoreConfig; // @Expose // @SerializedName("fetch_artifact_configuration") // private FetchArtifact fetchArtifact; // @Expose // @SerializedName("artifact_metadata") // private PublishMetadata metadata; // // public ArtifactStoreConfig getArtifactStoreConfig() { // return artifactStoreConfig; // } // // public PublishMetadata getMetadata() { // return metadata; // } // // public static FetchArtifactRequest fromJSON(String json) { // return GSON.fromJson(json, FetchArtifactRequest.class); // } // // public FetchArtifact getFetchArtifact() { // return fetchArtifact; // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/request/PublishArtifactRequest.java // public class PublishArtifactRequest { // @Expose // @SerializedName("agent_working_directory") // private String agentWorkingDir; // // @Expose // @SerializedName("artifact_store") // private ArtifactStore artifactStore; // // @Expose // @SerializedName("artifact_plan") // private ArtifactPlan artifactPlan; // // @Expose // @SerializedName("environment_variables") // private Map<String, String> environmentVariables; // private Object jobIdentifier; // // public PublishArtifactRequest() { // } // // public String getAgentWorkingDir() { // return agentWorkingDir; // } // // public ArtifactStore getArtifactStore() { // return artifactStore; // } // // public ArtifactPlan getArtifactPlan() { // return artifactPlan; // } // // public Map<String, String> getEnvironmentVariables() { // return environmentVariables; // } // // public static PublishArtifactRequest fromJSON(String json) { // return GSON.fromJson(json, PublishArtifactRequest.class); // } // // public String toJSON() { // return GSON.toJson(this); // } // // @Override // public boolean equals(Object o) { // if (this == o) return true; // if (!(o instanceof PublishArtifactRequest)) return false; // // PublishArtifactRequest that = (PublishArtifactRequest) o; // // if (agentWorkingDir != null ? !agentWorkingDir.equals(that.agentWorkingDir) : that.agentWorkingDir != null) // return false; // if (artifactStore != null ? !artifactStore.equals(that.artifactStore) : that.artifactStore != null) // return false; // return artifactPlan != null ? artifactPlan.equals(that.artifactPlan) : that.artifactPlan == null; // } // // @Override // public int hashCode() { // int result = agentWorkingDir != null ? agentWorkingDir.hashCode() : 0; // result = 31 * result + (artifactStore != null ? artifactStore.hashCode() : 0); // result = 31 * result + (artifactPlan != null ? artifactPlan.hashCode() : 0); // return result; // } // // public JobIdentifier getJobIdentifier() { // return new JobIdentifier(getEnvironmentVariables()); // } // } // // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/model/ArtifactStoreConfig.java // public static String artifactStoreMetadata() { // return GSON.toJson(Arrays.asList( // new Field("Url", new Metadata(true, false)), // new Field("Username", new Metadata(true, false)), // new Field("Password", new Metadata(true, true)) // )); // } // Path: plugins-for-tests/dummy-artifact-plugin/src/main/java/cd/go/artifact/dummy/DummyArtifactPlugin.java import cd.go.artifact.dummy.model.*; import cd.go.artifact.dummy.request.FetchArtifactRequest; import cd.go.artifact.dummy.request.PublishArtifactRequest; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.thoughtworks.go.plugin.api.GoApplicationAccessor; import com.thoughtworks.go.plugin.api.GoPlugin; import com.thoughtworks.go.plugin.api.GoPluginIdentifier; import com.thoughtworks.go.plugin.api.annotation.Extension; import com.thoughtworks.go.plugin.api.exceptions.UnhandledRequestTypeException; import com.thoughtworks.go.plugin.api.logging.Logger; import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; import com.thoughtworks.go.plugin.api.response.DefaultGoPluginApiResponse; import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse; import okhttp3.*; import java.io.File; import java.io.IOException; import java.util.Base64; import static cd.go.artifact.dummy.model.ArtifactStoreConfig.artifactStoreMetadata; import static java.lang.String.format; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; /* * Copyright 2021 ThoughtWorks, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package cd.go.artifact.dummy; @Extension public class DummyArtifactPlugin implements GoPlugin { public static final Gson GSON = new Gson(); public static final Logger LOG = Logger.getLoggerFor(DummyArtifactPlugin.class); public static final OkHttpClient CLIENT = new OkHttpClient(); @Override public void initializeGoApplicationAccessor(GoApplicationAccessor goApplicationAccessor) { } @Override public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException { final RequestFromServer requestFromServer = RequestFromServer.from(request.requestName()); try { switch (requestFromServer) { case REQUEST_GET_CAPABILITIES: return DefaultGoPluginApiResponse.success("{}"); case REQUEST_STORE_CONFIG_METADATA:
return DefaultGoPluginApiResponse.success(artifactStoreMetadata());
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/GoArtifactFactoryIntegrationTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/task/config/TaskConfigBuilder.java // public class TaskConfigBuilder { // // private final TaskConfig config; // // public TaskConfigBuilder() { // config = mock(TaskConfig.class); // } // // public TaskConfigBuilder uri(String path) { // when(config.getValue("URI")).thenReturn(path); // return this; // } // // public TaskConfigBuilder path(String path) { // when(config.getValue("Path")).thenReturn(path); // return this; // } // // public TaskConfigBuilder property(String name, String value) { // when(config.getValue("Properties")).thenReturn(format("%s=%s\n", name, value)); // return this; // } // // public TaskConfigBuilder uriIsFolder(boolean isFolder) { // when(config.getValue("uriIsFolder")).thenReturn(valueOf(isFolder)); // return this; // } // // public TaskConfig build() { // return config; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // }
import com.google.common.collect.ImmutableMap; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.TaskConfigBuilder; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static org.apache.commons.lang.StringUtils.join; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactoryIntegrationTest { private static GoArtifactFactory factory; private static TaskExecutionContext context; private Map<String, String> properties = ImmutableMap.<String, String>builder().put("name", "value").build(); @BeforeClass public static void beforeAll() throws Exception { Map<String, String> envVars = new HashMap<>(); envVars.put("GO_REVISION", "123");
// Path: src/test/java/com/tw/go/plugins/artifactory/task/config/TaskConfigBuilder.java // public class TaskConfigBuilder { // // private final TaskConfig config; // // public TaskConfigBuilder() { // config = mock(TaskConfig.class); // } // // public TaskConfigBuilder uri(String path) { // when(config.getValue("URI")).thenReturn(path); // return this; // } // // public TaskConfigBuilder path(String path) { // when(config.getValue("Path")).thenReturn(path); // return this; // } // // public TaskConfigBuilder property(String name, String value) { // when(config.getValue("Properties")).thenReturn(format("%s=%s\n", name, value)); // return this; // } // // public TaskConfigBuilder uriIsFolder(boolean isFolder) { // when(config.getValue("uriIsFolder")).thenReturn(valueOf(isFolder)); // return this; // } // // public TaskConfig build() { // return config; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/GoArtifactFactoryIntegrationTest.java import com.google.common.collect.ImmutableMap; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.TaskConfigBuilder; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static org.apache.commons.lang.StringUtils.join; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactoryIntegrationTest { private static GoArtifactFactory factory; private static TaskExecutionContext context; private Map<String, String> properties = ImmutableMap.<String, String>builder().put("name", "value").build(); @BeforeClass public static void beforeAll() throws Exception { Map<String, String> envVars = new HashMap<>(); envVars.put("GO_REVISION", "123");
context = new TaskExecutionContextBuilder()
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/GoArtifactFactoryIntegrationTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/task/config/TaskConfigBuilder.java // public class TaskConfigBuilder { // // private final TaskConfig config; // // public TaskConfigBuilder() { // config = mock(TaskConfig.class); // } // // public TaskConfigBuilder uri(String path) { // when(config.getValue("URI")).thenReturn(path); // return this; // } // // public TaskConfigBuilder path(String path) { // when(config.getValue("Path")).thenReturn(path); // return this; // } // // public TaskConfigBuilder property(String name, String value) { // when(config.getValue("Properties")).thenReturn(format("%s=%s\n", name, value)); // return this; // } // // public TaskConfigBuilder uriIsFolder(boolean isFolder) { // when(config.getValue("uriIsFolder")).thenReturn(valueOf(isFolder)); // return this; // } // // public TaskConfig build() { // return config; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // }
import com.google.common.collect.ImmutableMap; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.TaskConfigBuilder; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static org.apache.commons.lang.StringUtils.join; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactoryIntegrationTest { private static GoArtifactFactory factory; private static TaskExecutionContext context; private Map<String, String> properties = ImmutableMap.<String, String>builder().put("name", "value").build(); @BeforeClass public static void beforeAll() throws Exception { Map<String, String> envVars = new HashMap<>(); envVars.put("GO_REVISION", "123"); context = new TaskExecutionContextBuilder() .withWorkingDir(System.getProperty("user.dir")) .withEnvVars(envVars) .build(); factory = new GoArtifactFactory(); } @Test public void shouldCreateGoArtifacts() {
// Path: src/test/java/com/tw/go/plugins/artifactory/task/config/TaskConfigBuilder.java // public class TaskConfigBuilder { // // private final TaskConfig config; // // public TaskConfigBuilder() { // config = mock(TaskConfig.class); // } // // public TaskConfigBuilder uri(String path) { // when(config.getValue("URI")).thenReturn(path); // return this; // } // // public TaskConfigBuilder path(String path) { // when(config.getValue("Path")).thenReturn(path); // return this; // } // // public TaskConfigBuilder property(String name, String value) { // when(config.getValue("Properties")).thenReturn(format("%s=%s\n", name, value)); // return this; // } // // public TaskConfigBuilder uriIsFolder(boolean isFolder) { // when(config.getValue("uriIsFolder")).thenReturn(valueOf(isFolder)); // return this; // } // // public TaskConfig build() { // return config; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/GoArtifactFactoryIntegrationTest.java import com.google.common.collect.ImmutableMap; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.TaskConfigBuilder; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static org.apache.commons.lang.StringUtils.join; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactoryIntegrationTest { private static GoArtifactFactory factory; private static TaskExecutionContext context; private Map<String, String> properties = ImmutableMap.<String, String>builder().put("name", "value").build(); @BeforeClass public static void beforeAll() throws Exception { Map<String, String> envVars = new HashMap<>(); envVars.put("GO_REVISION", "123"); context = new TaskExecutionContextBuilder() .withWorkingDir(System.getProperty("user.dir")) .withEnvVars(envVars) .build(); factory = new GoArtifactFactory(); } @Test public void shouldCreateGoArtifacts() {
TaskConfig config = new TaskConfigBuilder()
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/GoArtifactFactoryIntegrationTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/task/config/TaskConfigBuilder.java // public class TaskConfigBuilder { // // private final TaskConfig config; // // public TaskConfigBuilder() { // config = mock(TaskConfig.class); // } // // public TaskConfigBuilder uri(String path) { // when(config.getValue("URI")).thenReturn(path); // return this; // } // // public TaskConfigBuilder path(String path) { // when(config.getValue("Path")).thenReturn(path); // return this; // } // // public TaskConfigBuilder property(String name, String value) { // when(config.getValue("Properties")).thenReturn(format("%s=%s\n", name, value)); // return this; // } // // public TaskConfigBuilder uriIsFolder(boolean isFolder) { // when(config.getValue("uriIsFolder")).thenReturn(valueOf(isFolder)); // return this; // } // // public TaskConfig build() { // return config; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // }
import com.google.common.collect.ImmutableMap; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.TaskConfigBuilder; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static org.apache.commons.lang.StringUtils.join; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactoryIntegrationTest { private static GoArtifactFactory factory; private static TaskExecutionContext context; private Map<String, String> properties = ImmutableMap.<String, String>builder().put("name", "value").build(); @BeforeClass public static void beforeAll() throws Exception { Map<String, String> envVars = new HashMap<>(); envVars.put("GO_REVISION", "123"); context = new TaskExecutionContextBuilder() .withWorkingDir(System.getProperty("user.dir")) .withEnvVars(envVars) .build(); factory = new GoArtifactFactory(); } @Test public void shouldCreateGoArtifacts() { TaskConfig config = new TaskConfigBuilder()
// Path: src/test/java/com/tw/go/plugins/artifactory/task/config/TaskConfigBuilder.java // public class TaskConfigBuilder { // // private final TaskConfig config; // // public TaskConfigBuilder() { // config = mock(TaskConfig.class); // } // // public TaskConfigBuilder uri(String path) { // when(config.getValue("URI")).thenReturn(path); // return this; // } // // public TaskConfigBuilder path(String path) { // when(config.getValue("Path")).thenReturn(path); // return this; // } // // public TaskConfigBuilder property(String name, String value) { // when(config.getValue("Properties")).thenReturn(format("%s=%s\n", name, value)); // return this; // } // // public TaskConfigBuilder uriIsFolder(boolean isFolder) { // when(config.getValue("uriIsFolder")).thenReturn(valueOf(isFolder)); // return this; // } // // public TaskConfig build() { // return config; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/GoArtifactFactoryIntegrationTest.java import com.google.common.collect.ImmutableMap; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.TaskConfigBuilder; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.junit.BeforeClass; import org.junit.Test; import java.io.File; import java.util.Collection; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static org.apache.commons.lang.StringUtils.join; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactoryIntegrationTest { private static GoArtifactFactory factory; private static TaskExecutionContext context; private Map<String, String> properties = ImmutableMap.<String, String>builder().put("name", "value").build(); @BeforeClass public static void beforeAll() throws Exception { Map<String, String> envVars = new HashMap<>(); envVars.put("GO_REVISION", "123"); context = new TaskExecutionContextBuilder() .withWorkingDir(System.getProperty("user.dir")) .withEnvVars(envVars) .build(); factory = new GoArtifactFactory(); } @Test public void shouldCreateGoArtifacts() { TaskConfig config = new TaskConfigBuilder()
.path(path("src", "test", "resources", "artifact.txt"))
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // }
import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) {
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) {
DirectoryScanner scanner = new DirectoryScanner(context.workingDir());
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // }
import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir());
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir());
Collection<File> files = scanner.scan(path.from(config));
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // }
import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir()); Collection<File> files = scanner.scan(path.from(config));
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir()); Collection<File> files = scanner.scan(path.from(config));
return transform(files, goArtifact(uriConfig.from(config), buildProperties.from(config), context));
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // }
import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir()); Collection<File> files = scanner.scan(path.from(config));
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir()); Collection<File> files = scanner.scan(path.from(config));
return transform(files, goArtifact(uriConfig.from(config), buildProperties.from(config), context));
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // }
import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner;
package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir()); Collection<File> files = scanner.scan(path.from(config)); return transform(files, goArtifact(uriConfig.from(config), buildProperties.from(config), context)); }
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // // Path: src/main/java/com/tw/go/plugins/artifactory/task/config/UriConfig.java // public class UriConfig { // private String uri; // private boolean folder; // // public UriConfig(String uri, boolean folder) { // this.uri = uri.endsWith("/") ? chop(uri) : uri; // this.folder = folder; // } // // public String uri() { // return uri; // } // // public boolean isFolder() { // return folder; // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/DirectoryScanner.java // public class DirectoryScanner { // private Logger logger = Logger.getLogger(this.getClass()); // // private Path root; // private final FileSystem fileSystem; // // public DirectoryScanner(String rootDirectory) { // root = Paths.get(rootDirectory); // fileSystem = FileSystems.getDefault(); // } // // public Collection<File> scan(String pattern) { // try { // String globPattern = format("glob:%s/%s", root, pattern).replace(separator, "/"); // // PathMatchingVisitor visitor = new PathMatchingVisitor(fileSystem.getPathMatcher(globPattern)); // Files.walkFileTree(root, EMPTY_SET, MAX_VALUE, visitor); // return matchingFilesFrom(visitor); // } // catch(IOException iox) { // throw new RuntimeException(iox); // } // } // // // private Collection<File> matchingFilesFrom(PathMatchingVisitor visitor) { // logger.debug("Scanned files:"); // // return transform(visitor.matched(), new Function<Path, File>() { // @Override // public File apply(Path path) { // logger.debug(path.toString()); // return path.toFile(); // } // }); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifactFactory.java import static com.google.common.collect.Collections2.transform; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import java.io.File; import java.util.Collection; import java.util.Map; import org.apache.commons.lang.text.StrSubstitutor; import com.google.common.base.Function; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.config.UriConfig; import com.tw.go.plugins.artifactory.utils.filesystem.DirectoryScanner; package com.tw.go.plugins.artifactory.model; public class GoArtifactFactory { public Collection<GoArtifact> createArtifacts(final TaskConfig config, TaskExecutionContext context) { DirectoryScanner scanner = new DirectoryScanner(context.workingDir()); Collection<File> files = scanner.scan(path.from(config)); return transform(files, goArtifact(uriConfig.from(config), buildProperties.from(config), context)); }
private Function<File, GoArtifact> goArtifact(final UriConfig config, final Map<String, String> properties, final TaskExecutionContext context) {
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/task/config/PathConfigElementTest.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement();
import com.google.common.base.Optional; import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.task.TaskConfig; import org.junit.Test; import java.nio.file.FileSystems; import java.nio.file.Path; import static com.google.common.collect.Iterables.getLast; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.task.config; public class PathConfigElementTest { public static final Iterable<Path> ROOT_DIRECTORIES = FileSystems.getDefault().getRootDirectories(); @Test public void shouldBeARelativePath() {
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<String> path = new PathConfigElement(); // Path: src/test/java/com/tw/go/plugins/artifactory/task/config/PathConfigElementTest.java import com.google.common.base.Optional; import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.task.TaskConfig; import org.junit.Test; import java.nio.file.FileSystems; import java.nio.file.Path; import static com.google.common.collect.Iterables.getLast; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.path; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.task.config; public class PathConfigElementTest { public static final Iterable<Path> ROOT_DIRECTORIES = FileSystems.getDefault().getRootDirectories(); @Test public void shouldBeARelativePath() {
Optional<ValidationError> error = path.validate(pathConfig("a/b"));
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/UploadMetadataTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/client/ArtifactoryUploadResponseBuilder.java // public class ArtifactoryUploadResponseBuilder { // private String repo = "repo"; // private String path = "path"; // private String created = "01-01-2014"; // private String createdBy = "go"; // private String downloadUri = "http://artifactory/path/to/artifact.ext"; // private String mimeType = "application/json"; // private String size = "21"; // private String uri = "path/to/artifact.ext"; // private List<ArtifactoryUploadResponse.Error> errors = asList(new ErrorBuilder().build("message", "status")); // private ArtifactoryUploadResponse.Checksums checksums = new ChecksumsBuilder().build("a", "b"); // private ArtifactoryUploadResponse.Checksums originalChecksums = new ChecksumsBuilder().build("c", "d"); // // public ArtifactoryUploadResponse build() { // ArtifactoryUploadResponse response = new ArtifactoryUploadResponse(); // response.setRepo(repo); // response.setPath(path); // response.setCreated(created); // response.setCreatedBy(createdBy); // response.setDownloadUri(downloadUri); // response.setMimeType(mimeType); // response.setSize(size); // response.setUri(uri); // response.setErrors(errors); // response.setChecksums(checksums); // response.setOriginalChecksums(originalChecksums); // return response; // } // // public ArtifactoryUploadResponseBuilder withErrors(List<ArtifactoryUploadResponse.Error> errors) { // this.errors = errors; // return this; // } // // private static class ChecksumsBuilder { // public ArtifactoryUploadResponse.Checksums build(String sha1, String md5) { // ArtifactoryUploadResponse.Checksums checksums = new ArtifactoryUploadResponse.Checksums(); // checksums.setMd5(md5); // checksums.setSha1(sha1); // return checksums; // } // } // // private static class ErrorBuilder { // public ArtifactoryUploadResponse.Error build(String message, String status) { // ArtifactoryUploadResponse.Error error = new ArtifactoryUploadResponse.Error(); // error.setMessage(message); // error.setStatus(status); // return error; // } // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // }
import com.tw.go.plugins.artifactory.client.ArtifactoryUploadResponseBuilder; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jfrog.build.client.ArtifactoryUploadResponse; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.read; import static java.util.Arrays.asList; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class UploadMetadataTest { @Test public void shouldReturnDataInJsonFormat() throws IOException {
// Path: src/test/java/com/tw/go/plugins/artifactory/client/ArtifactoryUploadResponseBuilder.java // public class ArtifactoryUploadResponseBuilder { // private String repo = "repo"; // private String path = "path"; // private String created = "01-01-2014"; // private String createdBy = "go"; // private String downloadUri = "http://artifactory/path/to/artifact.ext"; // private String mimeType = "application/json"; // private String size = "21"; // private String uri = "path/to/artifact.ext"; // private List<ArtifactoryUploadResponse.Error> errors = asList(new ErrorBuilder().build("message", "status")); // private ArtifactoryUploadResponse.Checksums checksums = new ChecksumsBuilder().build("a", "b"); // private ArtifactoryUploadResponse.Checksums originalChecksums = new ChecksumsBuilder().build("c", "d"); // // public ArtifactoryUploadResponse build() { // ArtifactoryUploadResponse response = new ArtifactoryUploadResponse(); // response.setRepo(repo); // response.setPath(path); // response.setCreated(created); // response.setCreatedBy(createdBy); // response.setDownloadUri(downloadUri); // response.setMimeType(mimeType); // response.setSize(size); // response.setUri(uri); // response.setErrors(errors); // response.setChecksums(checksums); // response.setOriginalChecksums(originalChecksums); // return response; // } // // public ArtifactoryUploadResponseBuilder withErrors(List<ArtifactoryUploadResponse.Error> errors) { // this.errors = errors; // return this; // } // // private static class ChecksumsBuilder { // public ArtifactoryUploadResponse.Checksums build(String sha1, String md5) { // ArtifactoryUploadResponse.Checksums checksums = new ArtifactoryUploadResponse.Checksums(); // checksums.setMd5(md5); // checksums.setSha1(sha1); // return checksums; // } // } // // private static class ErrorBuilder { // public ArtifactoryUploadResponse.Error build(String message, String status) { // ArtifactoryUploadResponse.Error error = new ArtifactoryUploadResponse.Error(); // error.setMessage(message); // error.setStatus(status); // return error; // } // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/UploadMetadataTest.java import com.tw.go.plugins.artifactory.client.ArtifactoryUploadResponseBuilder; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jfrog.build.client.ArtifactoryUploadResponse; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.read; import static java.util.Arrays.asList; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class UploadMetadataTest { @Test public void shouldReturnDataInJsonFormat() throws IOException {
ArtifactoryUploadResponse response = new ArtifactoryUploadResponseBuilder().build();
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/UploadMetadataTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/client/ArtifactoryUploadResponseBuilder.java // public class ArtifactoryUploadResponseBuilder { // private String repo = "repo"; // private String path = "path"; // private String created = "01-01-2014"; // private String createdBy = "go"; // private String downloadUri = "http://artifactory/path/to/artifact.ext"; // private String mimeType = "application/json"; // private String size = "21"; // private String uri = "path/to/artifact.ext"; // private List<ArtifactoryUploadResponse.Error> errors = asList(new ErrorBuilder().build("message", "status")); // private ArtifactoryUploadResponse.Checksums checksums = new ChecksumsBuilder().build("a", "b"); // private ArtifactoryUploadResponse.Checksums originalChecksums = new ChecksumsBuilder().build("c", "d"); // // public ArtifactoryUploadResponse build() { // ArtifactoryUploadResponse response = new ArtifactoryUploadResponse(); // response.setRepo(repo); // response.setPath(path); // response.setCreated(created); // response.setCreatedBy(createdBy); // response.setDownloadUri(downloadUri); // response.setMimeType(mimeType); // response.setSize(size); // response.setUri(uri); // response.setErrors(errors); // response.setChecksums(checksums); // response.setOriginalChecksums(originalChecksums); // return response; // } // // public ArtifactoryUploadResponseBuilder withErrors(List<ArtifactoryUploadResponse.Error> errors) { // this.errors = errors; // return this; // } // // private static class ChecksumsBuilder { // public ArtifactoryUploadResponse.Checksums build(String sha1, String md5) { // ArtifactoryUploadResponse.Checksums checksums = new ArtifactoryUploadResponse.Checksums(); // checksums.setMd5(md5); // checksums.setSha1(sha1); // return checksums; // } // } // // private static class ErrorBuilder { // public ArtifactoryUploadResponse.Error build(String message, String status) { // ArtifactoryUploadResponse.Error error = new ArtifactoryUploadResponse.Error(); // error.setMessage(message); // error.setStatus(status); // return error; // } // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // }
import com.tw.go.plugins.artifactory.client.ArtifactoryUploadResponseBuilder; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jfrog.build.client.ArtifactoryUploadResponse; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.read; import static java.util.Arrays.asList; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class UploadMetadataTest { @Test public void shouldReturnDataInJsonFormat() throws IOException { ArtifactoryUploadResponse response = new ArtifactoryUploadResponseBuilder().build(); UploadMetadata uploadMetadata = new UploadMetadata(asList(response));
// Path: src/test/java/com/tw/go/plugins/artifactory/client/ArtifactoryUploadResponseBuilder.java // public class ArtifactoryUploadResponseBuilder { // private String repo = "repo"; // private String path = "path"; // private String created = "01-01-2014"; // private String createdBy = "go"; // private String downloadUri = "http://artifactory/path/to/artifact.ext"; // private String mimeType = "application/json"; // private String size = "21"; // private String uri = "path/to/artifact.ext"; // private List<ArtifactoryUploadResponse.Error> errors = asList(new ErrorBuilder().build("message", "status")); // private ArtifactoryUploadResponse.Checksums checksums = new ChecksumsBuilder().build("a", "b"); // private ArtifactoryUploadResponse.Checksums originalChecksums = new ChecksumsBuilder().build("c", "d"); // // public ArtifactoryUploadResponse build() { // ArtifactoryUploadResponse response = new ArtifactoryUploadResponse(); // response.setRepo(repo); // response.setPath(path); // response.setCreated(created); // response.setCreatedBy(createdBy); // response.setDownloadUri(downloadUri); // response.setMimeType(mimeType); // response.setSize(size); // response.setUri(uri); // response.setErrors(errors); // response.setChecksums(checksums); // response.setOriginalChecksums(originalChecksums); // return response; // } // // public ArtifactoryUploadResponseBuilder withErrors(List<ArtifactoryUploadResponse.Error> errors) { // this.errors = errors; // return this; // } // // private static class ChecksumsBuilder { // public ArtifactoryUploadResponse.Checksums build(String sha1, String md5) { // ArtifactoryUploadResponse.Checksums checksums = new ArtifactoryUploadResponse.Checksums(); // checksums.setMd5(md5); // checksums.setSha1(sha1); // return checksums; // } // } // // private static class ErrorBuilder { // public ArtifactoryUploadResponse.Error build(String message, String status) { // ArtifactoryUploadResponse.Error error = new ArtifactoryUploadResponse.Error(); // error.setMessage(message); // error.setStatus(status); // return error; // } // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/UploadMetadataTest.java import com.tw.go.plugins.artifactory.client.ArtifactoryUploadResponseBuilder; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jfrog.build.client.ArtifactoryUploadResponse; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.read; import static java.util.Arrays.asList; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class UploadMetadataTest { @Test public void shouldReturnDataInJsonFormat() throws IOException { ArtifactoryUploadResponse response = new ArtifactoryUploadResponseBuilder().build(); UploadMetadata uploadMetadata = new UploadMetadata(asList(response));
String expectedContent = read(new File(path("src", "test", "resources", "uploadMetadata.json")));
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/UploadMetadataTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/client/ArtifactoryUploadResponseBuilder.java // public class ArtifactoryUploadResponseBuilder { // private String repo = "repo"; // private String path = "path"; // private String created = "01-01-2014"; // private String createdBy = "go"; // private String downloadUri = "http://artifactory/path/to/artifact.ext"; // private String mimeType = "application/json"; // private String size = "21"; // private String uri = "path/to/artifact.ext"; // private List<ArtifactoryUploadResponse.Error> errors = asList(new ErrorBuilder().build("message", "status")); // private ArtifactoryUploadResponse.Checksums checksums = new ChecksumsBuilder().build("a", "b"); // private ArtifactoryUploadResponse.Checksums originalChecksums = new ChecksumsBuilder().build("c", "d"); // // public ArtifactoryUploadResponse build() { // ArtifactoryUploadResponse response = new ArtifactoryUploadResponse(); // response.setRepo(repo); // response.setPath(path); // response.setCreated(created); // response.setCreatedBy(createdBy); // response.setDownloadUri(downloadUri); // response.setMimeType(mimeType); // response.setSize(size); // response.setUri(uri); // response.setErrors(errors); // response.setChecksums(checksums); // response.setOriginalChecksums(originalChecksums); // return response; // } // // public ArtifactoryUploadResponseBuilder withErrors(List<ArtifactoryUploadResponse.Error> errors) { // this.errors = errors; // return this; // } // // private static class ChecksumsBuilder { // public ArtifactoryUploadResponse.Checksums build(String sha1, String md5) { // ArtifactoryUploadResponse.Checksums checksums = new ArtifactoryUploadResponse.Checksums(); // checksums.setMd5(md5); // checksums.setSha1(sha1); // return checksums; // } // } // // private static class ErrorBuilder { // public ArtifactoryUploadResponse.Error build(String message, String status) { // ArtifactoryUploadResponse.Error error = new ArtifactoryUploadResponse.Error(); // error.setMessage(message); // error.setStatus(status); // return error; // } // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // }
import com.tw.go.plugins.artifactory.client.ArtifactoryUploadResponseBuilder; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jfrog.build.client.ArtifactoryUploadResponse; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.read; import static java.util.Arrays.asList; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class UploadMetadataTest { @Test public void shouldReturnDataInJsonFormat() throws IOException { ArtifactoryUploadResponse response = new ArtifactoryUploadResponseBuilder().build(); UploadMetadata uploadMetadata = new UploadMetadata(asList(response));
// Path: src/test/java/com/tw/go/plugins/artifactory/client/ArtifactoryUploadResponseBuilder.java // public class ArtifactoryUploadResponseBuilder { // private String repo = "repo"; // private String path = "path"; // private String created = "01-01-2014"; // private String createdBy = "go"; // private String downloadUri = "http://artifactory/path/to/artifact.ext"; // private String mimeType = "application/json"; // private String size = "21"; // private String uri = "path/to/artifact.ext"; // private List<ArtifactoryUploadResponse.Error> errors = asList(new ErrorBuilder().build("message", "status")); // private ArtifactoryUploadResponse.Checksums checksums = new ChecksumsBuilder().build("a", "b"); // private ArtifactoryUploadResponse.Checksums originalChecksums = new ChecksumsBuilder().build("c", "d"); // // public ArtifactoryUploadResponse build() { // ArtifactoryUploadResponse response = new ArtifactoryUploadResponse(); // response.setRepo(repo); // response.setPath(path); // response.setCreated(created); // response.setCreatedBy(createdBy); // response.setDownloadUri(downloadUri); // response.setMimeType(mimeType); // response.setSize(size); // response.setUri(uri); // response.setErrors(errors); // response.setChecksums(checksums); // response.setOriginalChecksums(originalChecksums); // return response; // } // // public ArtifactoryUploadResponseBuilder withErrors(List<ArtifactoryUploadResponse.Error> errors) { // this.errors = errors; // return this; // } // // private static class ChecksumsBuilder { // public ArtifactoryUploadResponse.Checksums build(String sha1, String md5) { // ArtifactoryUploadResponse.Checksums checksums = new ArtifactoryUploadResponse.Checksums(); // checksums.setMd5(md5); // checksums.setSha1(sha1); // return checksums; // } // } // // private static class ErrorBuilder { // public ArtifactoryUploadResponse.Error build(String message, String status) { // ArtifactoryUploadResponse.Error error = new ArtifactoryUploadResponse.Error(); // error.setMessage(message); // error.setStatus(status); // return error; // } // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/UploadMetadataTest.java import com.tw.go.plugins.artifactory.client.ArtifactoryUploadResponseBuilder; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.jfrog.build.client.ArtifactoryUploadResponse; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.path; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.read; import static java.util.Arrays.asList; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class UploadMetadataTest { @Test public void shouldReturnDataInJsonFormat() throws IOException { ArtifactoryUploadResponse response = new ArtifactoryUploadResponseBuilder().build(); UploadMetadata uploadMetadata = new UploadMetadata(asList(response));
String expectedContent = read(new File(path("src", "test", "resources", "uploadMetadata.json")));
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/task/GenericTask.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public abstract class ConfigElement<T> { // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // public static ConfigElement<String> path = new PathConfigElement(); // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // public List<String> names; // // protected ConfigElement(String... name) { // this.names = asList(name); // } // // public void addTo(TaskConfig taskConfig) { // for (String name : names) { // taskConfig.addProperty(name); // } // } // // public abstract T from(TaskConfig taskConfig); // public abstract Optional<ValidationError> validate(TaskConfig taskConfig); // } // // Path: src/main/java/com/tw/go/plugins/artifactory/task/view/TemplateBasedTaskView.java // public class TemplateBasedTaskView implements TaskView { // private final Logger logger = Logger.getLogger(this.getClass()); // // private final String title; // private final String template; // private final ClasspathResource classpathResource; // // public TemplateBasedTaskView(String title, String template) { // this.title = title; // this.template = template; // this.classpathResource = new ClasspathResource(); // } // // @Override // public String displayValue() { // return title; // } // // @Override // public String template() { // try { // return classpathResource.read(templatePath()); // } catch (IOException e) { // String message = format("Could not load view template [%s]!", template); // logger.error(message, e); // return message; // } // } // // private String templatePath() { // return format("view/%s.html", template); // } // }
import com.google.common.base.Optional; import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.response.validation.ValidationResult; import com.thoughtworks.go.plugin.api.task.Task; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskView; import com.tw.go.plugins.artifactory.task.config.ConfigElement; import com.tw.go.plugins.artifactory.task.view.TemplateBasedTaskView; import java.util.List;
package com.tw.go.plugins.artifactory.task; public abstract class GenericTask implements Task { private List<? extends ConfigElement> configs; public GenericTask(List<? extends ConfigElement> configs) { this.configs = configs; } @Override public final TaskConfig config() { TaskConfig taskConfig = new TaskConfig(); for (ConfigElement config : configs) { config.addTo(taskConfig); } return taskConfig; } @Override public final ValidationResult validate(TaskConfig taskConfig) { ValidationResult result = new ValidationResult(); for (ConfigElement config : configs) { Optional<ValidationError> error = config.validate(taskConfig); if (error.isPresent()) { result.addError(error.get()); } } return result; } @Override public TaskView view() {
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public abstract class ConfigElement<T> { // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // public static ConfigElement<String> path = new PathConfigElement(); // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // // public List<String> names; // // protected ConfigElement(String... name) { // this.names = asList(name); // } // // public void addTo(TaskConfig taskConfig) { // for (String name : names) { // taskConfig.addProperty(name); // } // } // // public abstract T from(TaskConfig taskConfig); // public abstract Optional<ValidationError> validate(TaskConfig taskConfig); // } // // Path: src/main/java/com/tw/go/plugins/artifactory/task/view/TemplateBasedTaskView.java // public class TemplateBasedTaskView implements TaskView { // private final Logger logger = Logger.getLogger(this.getClass()); // // private final String title; // private final String template; // private final ClasspathResource classpathResource; // // public TemplateBasedTaskView(String title, String template) { // this.title = title; // this.template = template; // this.classpathResource = new ClasspathResource(); // } // // @Override // public String displayValue() { // return title; // } // // @Override // public String template() { // try { // return classpathResource.read(templatePath()); // } catch (IOException e) { // String message = format("Could not load view template [%s]!", template); // logger.error(message, e); // return message; // } // } // // private String templatePath() { // return format("view/%s.html", template); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/task/GenericTask.java import com.google.common.base.Optional; import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.response.validation.ValidationResult; import com.thoughtworks.go.plugin.api.task.Task; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskView; import com.tw.go.plugins.artifactory.task.config.ConfigElement; import com.tw.go.plugins.artifactory.task.view.TemplateBasedTaskView; import java.util.List; package com.tw.go.plugins.artifactory.task; public abstract class GenericTask implements Task { private List<? extends ConfigElement> configs; public GenericTask(List<? extends ConfigElement> configs) { this.configs = configs; } @Override public final TaskConfig config() { TaskConfig taskConfig = new TaskConfig(); for (ConfigElement config : configs) { config.addTo(taskConfig); } return taskConfig; } @Override public final ValidationResult validate(TaskConfig taskConfig) { ValidationResult result = new ValidationResult(); for (ConfigElement config : configs) { Optional<ValidationError> error = config.validate(taskConfig); if (error.isPresent()) { result.addError(error.get()); } } return result; } @Override public TaskView view() {
return new TemplateBasedTaskView(taskDisplayName(), taskViewName());
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/task/config/UriConfigElementTest.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement();
import com.google.common.base.Optional; import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.task.TaskConfig; import org.junit.Test; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.task.config; public class UriConfigElementTest { @Test public void shouldInvalidateAnEmptyUri() {
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<UriConfig> uriConfig = new UriConfigElement(); // Path: src/test/java/com/tw/go/plugins/artifactory/task/config/UriConfigElementTest.java import com.google.common.base.Optional; import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.task.TaskConfig; import org.junit.Test; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.uriConfig; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.task.config; public class UriConfigElementTest { @Test public void shouldInvalidateAnEmptyUri() {
Optional<ValidationError> error = uriConfig.validate(config("", true));
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/task/publish/BuildArtifactPublisher.java
// Path: src/main/java/com/tw/go/plugins/artifactory/Logger.java // public class Logger implements Log { // public static Logger getLogger(Class clazz) { // return new Logger(com.thoughtworks.go.plugin.api.logging.Logger.getLoggerFor(clazz)); // } // // private com.thoughtworks.go.plugin.api.logging.Logger pluginLogger; // // private Logger(com.thoughtworks.go.plugin.api.logging.Logger pluginLogger) { // this.pluginLogger = pluginLogger; // } // // @Override // public void debug(String message) { // pluginLogger.debug(message); // } // // @Override // public void info(String message) { // pluginLogger.info(message); // } // // @Override // public void warn(String message) { // pluginLogger.warn(message); // } // // @Override // public void error(String message) { // pluginLogger.error(message); // } // // @Override // public void error(String message, Throwable throwable) { // error(format("%s. Root cause: %s\n%s", message, throwable.getMessage(), stackTrace(throwable))); // } // // private String stackTrace(Throwable throwable) { // StringBuilder stackTrace = new StringBuilder(); // for (StackTraceElement element : throwable.getStackTrace()) { // stackTrace.append("\t").append(element.toString()).append("\n"); // } // return stackTrace.toString(); // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/PluginProperties.java // public class PluginProperties { // private Logger logger = Logger.getLogger(getClass()); // // private static final String PROPERTIES = "plugin.properties"; // private Properties properties; // // public PluginProperties() { // try { // properties = new Properties(); // properties.load(getClass().getClassLoader().getResourceAsStream(PROPERTIES)); // } catch (IOException e) { // logger.error(e.getMessage(), e); // throw new RuntimeException("Error loading " + PROPERTIES, e); // } // } // // public String name() { // return (String) properties.get("name"); // } // // public String version() { // return (String) properties.get("version"); // } // }
import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.Logger; import com.tw.go.plugins.artifactory.PluginProperties; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.file.Paths;
package com.tw.go.plugins.artifactory.task.publish; public class BuildArtifactPublisher { private Logger logger = Logger.getLogger(getClass());
// Path: src/main/java/com/tw/go/plugins/artifactory/Logger.java // public class Logger implements Log { // public static Logger getLogger(Class clazz) { // return new Logger(com.thoughtworks.go.plugin.api.logging.Logger.getLoggerFor(clazz)); // } // // private com.thoughtworks.go.plugin.api.logging.Logger pluginLogger; // // private Logger(com.thoughtworks.go.plugin.api.logging.Logger pluginLogger) { // this.pluginLogger = pluginLogger; // } // // @Override // public void debug(String message) { // pluginLogger.debug(message); // } // // @Override // public void info(String message) { // pluginLogger.info(message); // } // // @Override // public void warn(String message) { // pluginLogger.warn(message); // } // // @Override // public void error(String message) { // pluginLogger.error(message); // } // // @Override // public void error(String message, Throwable throwable) { // error(format("%s. Root cause: %s\n%s", message, throwable.getMessage(), stackTrace(throwable))); // } // // private String stackTrace(Throwable throwable) { // StringBuilder stackTrace = new StringBuilder(); // for (StackTraceElement element : throwable.getStackTrace()) { // stackTrace.append("\t").append(element.toString()).append("\n"); // } // return stackTrace.toString(); // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/PluginProperties.java // public class PluginProperties { // private Logger logger = Logger.getLogger(getClass()); // // private static final String PROPERTIES = "plugin.properties"; // private Properties properties; // // public PluginProperties() { // try { // properties = new Properties(); // properties.load(getClass().getClassLoader().getResourceAsStream(PROPERTIES)); // } catch (IOException e) { // logger.error(e.getMessage(), e); // throw new RuntimeException("Error loading " + PROPERTIES, e); // } // } // // public String name() { // return (String) properties.get("name"); // } // // public String version() { // return (String) properties.get("version"); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/task/publish/BuildArtifactPublisher.java import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.Logger; import com.tw.go.plugins.artifactory.PluginProperties; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.file.Paths; package com.tw.go.plugins.artifactory.task.publish; public class BuildArtifactPublisher { private Logger logger = Logger.getLogger(getClass());
private PluginProperties plugin = new PluginProperties();
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcherWithIgnores.java
// Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/FieldHasDifferentValuesIn.java // public static FieldHasDifferentValuesIn fieldHasDifferentValues(Object expected, Object actual) { // return new FieldHasDifferentValuesIn(expected, actual); // }
import com.google.common.base.Optional; import com.google.common.base.Predicate; import org.hamcrest.Description; import java.lang.reflect.Field; import java.util.List; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.tryFind; import static com.google.common.collect.Lists.newArrayList; import static com.tw.go.plugins.artifactory.testutils.matchers.FieldHasDifferentValuesIn.fieldHasDifferentValues; import static java.util.Arrays.asList;
package com.tw.go.plugins.artifactory.testutils.matchers; class DeepEqualsMatcherWithIgnores<T> extends DeepEqualsMatcher<T> { private List<String> ignoredFieldNames; DeepEqualsMatcherWithIgnores(T expected, List<String> ignoredFieldNames) { super(expected); this.ignoredFieldNames = ignoredFieldNames; } @Override protected boolean matchesSafely(T actual) {
// Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/FieldHasDifferentValuesIn.java // public static FieldHasDifferentValuesIn fieldHasDifferentValues(Object expected, Object actual) { // return new FieldHasDifferentValuesIn(expected, actual); // } // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcherWithIgnores.java import com.google.common.base.Optional; import com.google.common.base.Predicate; import org.hamcrest.Description; import java.lang.reflect.Field; import java.util.List; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.tryFind; import static com.google.common.collect.Lists.newArrayList; import static com.tw.go.plugins.artifactory.testutils.matchers.FieldHasDifferentValuesIn.fieldHasDifferentValues; import static java.util.Arrays.asList; package com.tw.go.plugins.artifactory.testutils.matchers; class DeepEqualsMatcherWithIgnores<T> extends DeepEqualsMatcher<T> { private List<String> ignoredFieldNames; DeepEqualsMatcherWithIgnores(T expected, List<String> ignoredFieldNames) { super(expected); this.ignoredFieldNames = ignoredFieldNames; } @Override protected boolean matchesSafely(T actual) {
Optional<Field> fieldWithDifferentValues = tryFind(unignoredFields(), fieldHasDifferentValues(expected, actual));
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/task/config/BuildPropertiesConfigElementTest.java
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement();
import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskConfigProperty; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.task.config; public class BuildPropertiesConfigElementTest { @Test public void shouldValidateKeyValuePairsSeparatedByNewline() { TaskConfig taskConfig = propertiesConfig("a=b");
// Path: src/main/java/com/tw/go/plugins/artifactory/task/config/ConfigElement.java // public static ConfigElement<Map<String, String>> buildProperties = new BuildPropertiesConfigElement(); // Path: src/test/java/com/tw/go/plugins/artifactory/task/config/BuildPropertiesConfigElementTest.java import com.thoughtworks.go.plugin.api.response.validation.ValidationError; import com.thoughtworks.go.plugin.api.task.TaskConfig; import com.thoughtworks.go.plugin.api.task.TaskConfigProperty; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.task.config.ConfigElement.buildProperties; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.task.config; public class BuildPropertiesConfigElementTest { @Test public void shouldValidateKeyValuePairsSeparatedByNewline() { TaskConfig taskConfig = propertiesConfig("a=b");
ASSERT.that(buildProperties.validate(taskConfig)).isAbsent();
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/task/EnvironmentDataTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // }
import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import org.junit.Test; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.task.EnvironmentData.ARTIFACTORY_URL; import static com.tw.go.plugins.artifactory.task.EnvironmentData.PIPELINE_VALUESTREAM_URL; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.task; public class EnvironmentDataTest { @Test public void shouldReturnEnvironmentVariableValue() {
// Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // } // Path: src/test/java/com/tw/go/plugins/artifactory/task/EnvironmentDataTest.java import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import org.junit.Test; import java.util.HashMap; import java.util.Map; import static com.tw.go.plugins.artifactory.task.EnvironmentData.ARTIFACTORY_URL; import static com.tw.go.plugins.artifactory.task.EnvironmentData.PIPELINE_VALUESTREAM_URL; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.task; public class EnvironmentDataTest { @Test public void shouldReturnEnvironmentVariableValue() {
EnvironmentVariables environmentVariables = asEnvVars(map("ARTIFACTORY_URL", "http://localhost"));
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java
// Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifact.java // public class GoArtifact { // private String repository; // private String localPath; // private String remotePath; // private Splitter splitter; // private Map<String, String> properties = new HashMap<>(); // private Map<String, String> checksums = emptyMap(); // // // public GoArtifact(String localPath, String remotePath) { // this.localPath = localPath; // this.splitter = Splitter.on("/").omitEmptyStrings().trimResults(); // // List<String> segments = splitter.limit(2).splitToList(remotePath); // this.repository = segments.get(0); // this.remotePath = segments.get(1); // } // // public String localPath() { // return localPath; // } // // public String repository() { // return repository; // } // // public String remotePath() { // return remotePath; // } // // public String remoteName() { // return getLast(splitter.split(remotePath)); // } // // public void properties(Map<String, String> properties) { // this.properties = properties; // } // // public Map<String, String> properties() { // return properties; // } // // public String sha1() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("SHA1"); // } // // public String md5() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("MD5"); // } // // @Override // public int hashCode() { // int result = repository.hashCode(); // result = 31 * result + localPath.hashCode(); // result = 31 * result + remotePath.hashCode(); // result = 31 * result + (properties != null ? properties.hashCode() : 0); // return result; // } // // @Override // public boolean equals(Object o) { // if (!(o instanceof GoArtifact)) return false; // // GoArtifact artifact = (GoArtifact) o; // // return remotePath.equals(artifact.remotePath) // && localPath.equals(artifact.localPath) // && repository.equals(artifact.repository) // && properties.equals(artifact.properties); // } // // @Override // public String toString() { // return Objects.toStringHelper(this) // .add("localPath", localPath) // .add("remotePath", format("%s/%s", repository, remotePath)) // .add("properties", properties) // .toString(); // } // // private Map<String, String> computeChecksums() { // try { // return FileChecksumCalculator.calculateChecksums(new File(localPath), "SHA1", "MD5"); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoBuildDetails.java // public class GoBuildDetails { // private String name; // private String number; // private String url; // private DateTime startedAt; // private Collection<GoArtifact> goArtifacts = new ArrayList<>(); // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails(String name, String number, DateTime startedAt) { // this.name = name; // this.number = number; // this.startedAt = startedAt; // } // // public String buildName() { // return name; // } // // public String buildNumber() { // return number; // } // // public DateTime startedAt() { // return startedAt; // } // // public void artifacts(Collection<GoArtifact> artifacts) { // goArtifacts = artifacts; // } // // public List<GoArtifact> artifacts() { // return copyOf(goArtifacts); // } // // public String url() { // return url; // } // // public void url(String url) { // this.url = url; // } // // public void environmentVariables(Map<String, String> envVars) { // this.envVars = envVars; // } // // public Map<String, String> environmentVariables() { // return copyOf(this.envVars); // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactory.java // public class GoBuildDetailsFactory { // private static final String OBFUSCATED = "****"; // // public GoBuildDetails createBuildDetails(EnvironmentVariables envVars, Collection<GoArtifact> buildArtifacts) { // GoBuildDetails buildDetails = // new GoBuildDetails(GO_PIPELINE_NAME.from(envVars), buildNumber(envVars), DateTime.now()); // // buildDetails.url(PIPELINE_VALUESTREAM_URL.from(envVars)); // buildDetails.artifacts(buildArtifacts); // buildDetails.environmentVariables(obfuscate(envVars)); // // return buildDetails; // } // // private String buildNumber(EnvironmentVariables envVars) { // return format("%s.%s", GO_PIPELINE_COUNTER.from(envVars), GO_STAGE_COUNTER.from(envVars)); // } // // private Map<String, String> obfuscate(EnvironmentVariables envVars) { // final Console.SecureEnvVarSpecifier secureEnvSpecifier = envVars.secureEnvSpecifier(); // // return transformEntries(envVars.asMap(), new Maps.EntryTransformer<String, String, String>() { // @Override // public String transformEntry(String key, String value) { // return secureEnvSpecifier.isSecure(key) ? OBFUSCATED : value; // } // }); // } // }
import com.tw.go.plugins.artifactory.model.GoArtifact; import com.tw.go.plugins.artifactory.model.GoBuildDetails; import com.tw.go.plugins.artifactory.model.GoBuildDetailsFactory; import org.joda.time.DateTime; import java.util.HashMap; import java.util.Map; import java.util.Properties; import static java.util.Arrays.asList;
package com.tw.go.plugins.artifactory; public class GoBuildDetailsBuilder { private String buildName; private String buildNumber; private DateTime startedAt;
// Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifact.java // public class GoArtifact { // private String repository; // private String localPath; // private String remotePath; // private Splitter splitter; // private Map<String, String> properties = new HashMap<>(); // private Map<String, String> checksums = emptyMap(); // // // public GoArtifact(String localPath, String remotePath) { // this.localPath = localPath; // this.splitter = Splitter.on("/").omitEmptyStrings().trimResults(); // // List<String> segments = splitter.limit(2).splitToList(remotePath); // this.repository = segments.get(0); // this.remotePath = segments.get(1); // } // // public String localPath() { // return localPath; // } // // public String repository() { // return repository; // } // // public String remotePath() { // return remotePath; // } // // public String remoteName() { // return getLast(splitter.split(remotePath)); // } // // public void properties(Map<String, String> properties) { // this.properties = properties; // } // // public Map<String, String> properties() { // return properties; // } // // public String sha1() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("SHA1"); // } // // public String md5() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("MD5"); // } // // @Override // public int hashCode() { // int result = repository.hashCode(); // result = 31 * result + localPath.hashCode(); // result = 31 * result + remotePath.hashCode(); // result = 31 * result + (properties != null ? properties.hashCode() : 0); // return result; // } // // @Override // public boolean equals(Object o) { // if (!(o instanceof GoArtifact)) return false; // // GoArtifact artifact = (GoArtifact) o; // // return remotePath.equals(artifact.remotePath) // && localPath.equals(artifact.localPath) // && repository.equals(artifact.repository) // && properties.equals(artifact.properties); // } // // @Override // public String toString() { // return Objects.toStringHelper(this) // .add("localPath", localPath) // .add("remotePath", format("%s/%s", repository, remotePath)) // .add("properties", properties) // .toString(); // } // // private Map<String, String> computeChecksums() { // try { // return FileChecksumCalculator.calculateChecksums(new File(localPath), "SHA1", "MD5"); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoBuildDetails.java // public class GoBuildDetails { // private String name; // private String number; // private String url; // private DateTime startedAt; // private Collection<GoArtifact> goArtifacts = new ArrayList<>(); // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails(String name, String number, DateTime startedAt) { // this.name = name; // this.number = number; // this.startedAt = startedAt; // } // // public String buildName() { // return name; // } // // public String buildNumber() { // return number; // } // // public DateTime startedAt() { // return startedAt; // } // // public void artifacts(Collection<GoArtifact> artifacts) { // goArtifacts = artifacts; // } // // public List<GoArtifact> artifacts() { // return copyOf(goArtifacts); // } // // public String url() { // return url; // } // // public void url(String url) { // this.url = url; // } // // public void environmentVariables(Map<String, String> envVars) { // this.envVars = envVars; // } // // public Map<String, String> environmentVariables() { // return copyOf(this.envVars); // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactory.java // public class GoBuildDetailsFactory { // private static final String OBFUSCATED = "****"; // // public GoBuildDetails createBuildDetails(EnvironmentVariables envVars, Collection<GoArtifact> buildArtifacts) { // GoBuildDetails buildDetails = // new GoBuildDetails(GO_PIPELINE_NAME.from(envVars), buildNumber(envVars), DateTime.now()); // // buildDetails.url(PIPELINE_VALUESTREAM_URL.from(envVars)); // buildDetails.artifacts(buildArtifacts); // buildDetails.environmentVariables(obfuscate(envVars)); // // return buildDetails; // } // // private String buildNumber(EnvironmentVariables envVars) { // return format("%s.%s", GO_PIPELINE_COUNTER.from(envVars), GO_STAGE_COUNTER.from(envVars)); // } // // private Map<String, String> obfuscate(EnvironmentVariables envVars) { // final Console.SecureEnvVarSpecifier secureEnvSpecifier = envVars.secureEnvSpecifier(); // // return transformEntries(envVars.asMap(), new Maps.EntryTransformer<String, String, String>() { // @Override // public String transformEntry(String key, String value) { // return secureEnvSpecifier.isSecure(key) ? OBFUSCATED : value; // } // }); // } // } // Path: src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java import com.tw.go.plugins.artifactory.model.GoArtifact; import com.tw.go.plugins.artifactory.model.GoBuildDetails; import com.tw.go.plugins.artifactory.model.GoBuildDetailsFactory; import org.joda.time.DateTime; import java.util.HashMap; import java.util.Map; import java.util.Properties; import static java.util.Arrays.asList; package com.tw.go.plugins.artifactory; public class GoBuildDetailsBuilder { private String buildName; private String buildNumber; private DateTime startedAt;
private GoArtifact artifact;
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/task/publish/BuildArtifactPublisherIntegrationTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public class FilesystemUtils { // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // } // // public static void write(String path, String content) throws IOException { // FileUtils.forceMkdir(Paths.get(path).getParent().toFile()); // // try (OutputStream stream = new FileOutputStream(new File(path))) { // IOUtils.write(content, stream, "UTF-8"); // } // } // // public static void delete(File file) throws IOException { // FileUtils.forceDelete(file); // } // }
import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.*; import static java.lang.System.getProperty; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat;
package com.tw.go.plugins.artifactory.task.publish; public class BuildArtifactPublisherIntegrationTest { private static String pluginId = "com.tw.go.plugins.go-artifactory-plugin"; private String tempFilePath = path(getProperty("java.io.tmpdir"), pluginId, "name");
// Path: src/test/java/com/tw/go/plugins/artifactory/task/executor/TaskExecutionContextBuilder.java // public class TaskExecutionContextBuilder { // private Map<String, String> envVars = new HashMap<>(); // private String workingDir; // // public TaskExecutionContextBuilder withEnvVars(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // // public TaskExecutionContextBuilder withWorkingDir(String workingDir) { // this.workingDir = workingDir; // return this; // } // // public TaskExecutionContext build() { // EnvironmentVariables environmentVariables = mock(EnvironmentVariables.class); // when(environmentVariables.asMap()).thenReturn(envVars); // when(environmentVariables.secureEnvSpecifier()).thenReturn(mock(Console.SecureEnvVarSpecifier.class)); // // TaskExecutionContext context = mock(TaskExecutionContext.class); // when(context.environment()).thenReturn(environmentVariables); // when(context.workingDir()).thenReturn(workingDir); // // Console console = mock(Console.class); // when(context.console()).thenReturn(console); // // return context; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/FilesystemUtils.java // public class FilesystemUtils { // public static String path(String first, String... more) { // return Paths.get(first, more).toString(); // } // // public static String read(File file) throws IOException { // try(InputStream stream = new FileInputStream(file)) { // return join(IOUtils.readLines(stream), "\n").trim(); // } // } // // public static void write(String path, String content) throws IOException { // FileUtils.forceMkdir(Paths.get(path).getParent().toFile()); // // try (OutputStream stream = new FileOutputStream(new File(path))) { // IOUtils.write(content, stream, "UTF-8"); // } // } // // public static void delete(File file) throws IOException { // FileUtils.forceDelete(file); // } // } // Path: src/test/java/com/tw/go/plugins/artifactory/task/publish/BuildArtifactPublisherIntegrationTest.java import com.thoughtworks.go.plugin.api.task.TaskExecutionContext; import com.tw.go.plugins.artifactory.task.executor.TaskExecutionContextBuilder; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Test; import java.io.File; import java.io.IOException; import static com.tw.go.plugins.artifactory.testutils.FilesystemUtils.*; import static java.lang.System.getProperty; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; package com.tw.go.plugins.artifactory.task.publish; public class BuildArtifactPublisherIntegrationTest { private static String pluginId = "com.tw.go.plugins.go-artifactory-plugin"; private String tempFilePath = path(getProperty("java.io.tmpdir"), pluginId, "name");
private TaskExecutionContext context = new TaskExecutionContextBuilder()
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/client/BuildMap.java
// Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifact.java // public class GoArtifact { // private String repository; // private String localPath; // private String remotePath; // private Splitter splitter; // private Map<String, String> properties = new HashMap<>(); // private Map<String, String> checksums = emptyMap(); // // // public GoArtifact(String localPath, String remotePath) { // this.localPath = localPath; // this.splitter = Splitter.on("/").omitEmptyStrings().trimResults(); // // List<String> segments = splitter.limit(2).splitToList(remotePath); // this.repository = segments.get(0); // this.remotePath = segments.get(1); // } // // public String localPath() { // return localPath; // } // // public String repository() { // return repository; // } // // public String remotePath() { // return remotePath; // } // // public String remoteName() { // return getLast(splitter.split(remotePath)); // } // // public void properties(Map<String, String> properties) { // this.properties = properties; // } // // public Map<String, String> properties() { // return properties; // } // // public String sha1() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("SHA1"); // } // // public String md5() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("MD5"); // } // // @Override // public int hashCode() { // int result = repository.hashCode(); // result = 31 * result + localPath.hashCode(); // result = 31 * result + remotePath.hashCode(); // result = 31 * result + (properties != null ? properties.hashCode() : 0); // return result; // } // // @Override // public boolean equals(Object o) { // if (!(o instanceof GoArtifact)) return false; // // GoArtifact artifact = (GoArtifact) o; // // return remotePath.equals(artifact.remotePath) // && localPath.equals(artifact.localPath) // && repository.equals(artifact.repository) // && properties.equals(artifact.properties); // } // // @Override // public String toString() { // return Objects.toStringHelper(this) // .add("localPath", localPath) // .add("remotePath", format("%s/%s", repository, remotePath)) // .add("properties", properties) // .toString(); // } // // private Map<String, String> computeChecksums() { // try { // return FileChecksumCalculator.calculateChecksums(new File(localPath), "SHA1", "MD5"); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoBuildDetails.java // public class GoBuildDetails { // private String name; // private String number; // private String url; // private DateTime startedAt; // private Collection<GoArtifact> goArtifacts = new ArrayList<>(); // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails(String name, String number, DateTime startedAt) { // this.name = name; // this.number = number; // this.startedAt = startedAt; // } // // public String buildName() { // return name; // } // // public String buildNumber() { // return number; // } // // public DateTime startedAt() { // return startedAt; // } // // public void artifacts(Collection<GoArtifact> artifacts) { // goArtifacts = artifacts; // } // // public List<GoArtifact> artifacts() { // return copyOf(goArtifacts); // } // // public String url() { // return url; // } // // public void url(String url) { // this.url = url; // } // // public void environmentVariables(Map<String, String> envVars) { // this.envVars = envVars; // } // // public Map<String, String> environmentVariables() { // return copyOf(this.envVars); // } // }
import com.google.common.base.Function; import com.tw.go.plugins.artifactory.model.GoArtifact; import com.tw.go.plugins.artifactory.model.GoBuildDetails; import org.jfrog.build.api.Artifact; import org.jfrog.build.api.Build; import org.jfrog.build.api.Module; import org.jfrog.build.api.builder.ArtifactBuilder; import org.jfrog.build.api.builder.BuildInfoBuilder; import org.jfrog.build.api.builder.ModuleBuilder; import java.util.*; import static com.google.common.collect.Collections2.transform; import static com.google.common.collect.Lists.newArrayList; import static org.jfrog.build.api.Build.STARTED_FORMAT; import static org.jfrog.build.api.BuildInfoProperties.BUILD_INFO_ENVIRONMENT_PREFIX; import static org.joda.time.format.DateTimeFormat.forPattern;
package com.tw.go.plugins.artifactory.client; public class BuildMap implements Function<GoBuildDetails, Build> { @Override public Build apply(GoBuildDetails buildDetails) { Module module = new ModuleBuilder() .id(buildDetails.buildName()) .artifacts(artifactsFrom(buildDetails)) .build(); return new BuildInfoBuilder(buildDetails.buildName()) .url(buildDetails.url()) .number(buildDetails.buildNumber()) .started(forPattern(STARTED_FORMAT).print(buildDetails.startedAt())) .addModule(module) .properties(environmentProperties(buildDetails)) .build(); } private List<Artifact> artifactsFrom(GoBuildDetails buildDetails) {
// Path: src/main/java/com/tw/go/plugins/artifactory/model/GoArtifact.java // public class GoArtifact { // private String repository; // private String localPath; // private String remotePath; // private Splitter splitter; // private Map<String, String> properties = new HashMap<>(); // private Map<String, String> checksums = emptyMap(); // // // public GoArtifact(String localPath, String remotePath) { // this.localPath = localPath; // this.splitter = Splitter.on("/").omitEmptyStrings().trimResults(); // // List<String> segments = splitter.limit(2).splitToList(remotePath); // this.repository = segments.get(0); // this.remotePath = segments.get(1); // } // // public String localPath() { // return localPath; // } // // public String repository() { // return repository; // } // // public String remotePath() { // return remotePath; // } // // public String remoteName() { // return getLast(splitter.split(remotePath)); // } // // public void properties(Map<String, String> properties) { // this.properties = properties; // } // // public Map<String, String> properties() { // return properties; // } // // public String sha1() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("SHA1"); // } // // public String md5() { // if (checksums.isEmpty()) // this.checksums = computeChecksums(); // // return checksums.get("MD5"); // } // // @Override // public int hashCode() { // int result = repository.hashCode(); // result = 31 * result + localPath.hashCode(); // result = 31 * result + remotePath.hashCode(); // result = 31 * result + (properties != null ? properties.hashCode() : 0); // return result; // } // // @Override // public boolean equals(Object o) { // if (!(o instanceof GoArtifact)) return false; // // GoArtifact artifact = (GoArtifact) o; // // return remotePath.equals(artifact.remotePath) // && localPath.equals(artifact.localPath) // && repository.equals(artifact.repository) // && properties.equals(artifact.properties); // } // // @Override // public String toString() { // return Objects.toStringHelper(this) // .add("localPath", localPath) // .add("remotePath", format("%s/%s", repository, remotePath)) // .add("properties", properties) // .toString(); // } // // private Map<String, String> computeChecksums() { // try { // return FileChecksumCalculator.calculateChecksums(new File(localPath), "SHA1", "MD5"); // } catch (Exception e) { // throw new RuntimeException(e); // } // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/model/GoBuildDetails.java // public class GoBuildDetails { // private String name; // private String number; // private String url; // private DateTime startedAt; // private Collection<GoArtifact> goArtifacts = new ArrayList<>(); // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails(String name, String number, DateTime startedAt) { // this.name = name; // this.number = number; // this.startedAt = startedAt; // } // // public String buildName() { // return name; // } // // public String buildNumber() { // return number; // } // // public DateTime startedAt() { // return startedAt; // } // // public void artifacts(Collection<GoArtifact> artifacts) { // goArtifacts = artifacts; // } // // public List<GoArtifact> artifacts() { // return copyOf(goArtifacts); // } // // public String url() { // return url; // } // // public void url(String url) { // this.url = url; // } // // public void environmentVariables(Map<String, String> envVars) { // this.envVars = envVars; // } // // public Map<String, String> environmentVariables() { // return copyOf(this.envVars); // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/client/BuildMap.java import com.google.common.base.Function; import com.tw.go.plugins.artifactory.model.GoArtifact; import com.tw.go.plugins.artifactory.model.GoBuildDetails; import org.jfrog.build.api.Artifact; import org.jfrog.build.api.Build; import org.jfrog.build.api.Module; import org.jfrog.build.api.builder.ArtifactBuilder; import org.jfrog.build.api.builder.BuildInfoBuilder; import org.jfrog.build.api.builder.ModuleBuilder; import java.util.*; import static com.google.common.collect.Collections2.transform; import static com.google.common.collect.Lists.newArrayList; import static org.jfrog.build.api.Build.STARTED_FORMAT; import static org.jfrog.build.api.BuildInfoProperties.BUILD_INFO_ENVIRONMENT_PREFIX; import static org.joda.time.format.DateTimeFormat.forPattern; package com.tw.go.plugins.artifactory.client; public class BuildMap implements Function<GoBuildDetails, Build> { @Override public Build apply(GoBuildDetails buildDetails) { Module module = new ModuleBuilder() .id(buildDetails.buildName()) .artifacts(artifactsFrom(buildDetails)) .build(); return new BuildInfoBuilder(buildDetails.buildName()) .url(buildDetails.url()) .number(buildDetails.buildNumber()) .started(forPattern(STARTED_FORMAT).print(buildDetails.startedAt())) .addModule(module) .properties(environmentProperties(buildDetails)) .build(); } private List<Artifact> artifactsFrom(GoBuildDetails buildDetails) {
return newArrayList(transform(buildDetails.artifacts(), new Function<GoArtifact, Artifact>() {
tusharm/go-artifactory-plugin
src/main/java/com/tw/go/plugins/artifactory/task/view/TemplateBasedTaskView.java
// Path: src/main/java/com/tw/go/plugins/artifactory/Logger.java // public class Logger implements Log { // public static Logger getLogger(Class clazz) { // return new Logger(com.thoughtworks.go.plugin.api.logging.Logger.getLoggerFor(clazz)); // } // // private com.thoughtworks.go.plugin.api.logging.Logger pluginLogger; // // private Logger(com.thoughtworks.go.plugin.api.logging.Logger pluginLogger) { // this.pluginLogger = pluginLogger; // } // // @Override // public void debug(String message) { // pluginLogger.debug(message); // } // // @Override // public void info(String message) { // pluginLogger.info(message); // } // // @Override // public void warn(String message) { // pluginLogger.warn(message); // } // // @Override // public void error(String message) { // pluginLogger.error(message); // } // // @Override // public void error(String message, Throwable throwable) { // error(format("%s. Root cause: %s\n%s", message, throwable.getMessage(), stackTrace(throwable))); // } // // private String stackTrace(Throwable throwable) { // StringBuilder stackTrace = new StringBuilder(); // for (StackTraceElement element : throwable.getStackTrace()) { // stackTrace.append("\t").append(element.toString()).append("\n"); // } // return stackTrace.toString(); // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/ClasspathResource.java // public class ClasspathResource { // private static final String UTF_8 = "UTF-8"; // // public String read(String resourcePath) throws IOException { // InputStream inputStream = getClass().getClassLoader().getResourceAsStream(resourcePath); // // try (InputStreamReader reader = new InputStreamReader(inputStream, UTF_8)) { // return CharStreams.toString(reader); // } // } // }
import com.thoughtworks.go.plugin.api.task.TaskView; import com.tw.go.plugins.artifactory.Logger; import com.tw.go.plugins.artifactory.utils.filesystem.ClasspathResource; import java.io.IOException; import static java.lang.String.format;
package com.tw.go.plugins.artifactory.task.view; public class TemplateBasedTaskView implements TaskView { private final Logger logger = Logger.getLogger(this.getClass()); private final String title; private final String template;
// Path: src/main/java/com/tw/go/plugins/artifactory/Logger.java // public class Logger implements Log { // public static Logger getLogger(Class clazz) { // return new Logger(com.thoughtworks.go.plugin.api.logging.Logger.getLoggerFor(clazz)); // } // // private com.thoughtworks.go.plugin.api.logging.Logger pluginLogger; // // private Logger(com.thoughtworks.go.plugin.api.logging.Logger pluginLogger) { // this.pluginLogger = pluginLogger; // } // // @Override // public void debug(String message) { // pluginLogger.debug(message); // } // // @Override // public void info(String message) { // pluginLogger.info(message); // } // // @Override // public void warn(String message) { // pluginLogger.warn(message); // } // // @Override // public void error(String message) { // pluginLogger.error(message); // } // // @Override // public void error(String message, Throwable throwable) { // error(format("%s. Root cause: %s\n%s", message, throwable.getMessage(), stackTrace(throwable))); // } // // private String stackTrace(Throwable throwable) { // StringBuilder stackTrace = new StringBuilder(); // for (StackTraceElement element : throwable.getStackTrace()) { // stackTrace.append("\t").append(element.toString()).append("\n"); // } // return stackTrace.toString(); // } // } // // Path: src/main/java/com/tw/go/plugins/artifactory/utils/filesystem/ClasspathResource.java // public class ClasspathResource { // private static final String UTF_8 = "UTF-8"; // // public String read(String resourcePath) throws IOException { // InputStream inputStream = getClass().getClassLoader().getResourceAsStream(resourcePath); // // try (InputStreamReader reader = new InputStreamReader(inputStream, UTF_8)) { // return CharStreams.toString(reader); // } // } // } // Path: src/main/java/com/tw/go/plugins/artifactory/task/view/TemplateBasedTaskView.java import com.thoughtworks.go.plugin.api.task.TaskView; import com.tw.go.plugins.artifactory.Logger; import com.tw.go.plugins.artifactory.utils.filesystem.ClasspathResource; import java.io.IOException; import static java.lang.String.format; package com.tw.go.plugins.artifactory.task.view; public class TemplateBasedTaskView implements TaskView { private final Logger logger = Logger.getLogger(this.getClass()); private final String title; private final String template;
private final ClasspathResource classpathResource;
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactoryTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java // public class GoBuildDetailsBuilder { // private String buildName; // private String buildNumber; // private DateTime startedAt; // private GoArtifact artifact; // private String buildUrl; // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails build() { // GoBuildDetails buildDetails = new GoBuildDetails(buildName, buildNumber, startedAt); // buildDetails.artifacts(asList(artifact)); // buildDetails.url(buildUrl); // buildDetails.environmentVariables(envVars); // // return buildDetails; // } // // public GoBuildDetailsBuilder buildName(String name) { // this.buildName = name; // return this; // } // // public GoBuildDetailsBuilder buildNumber(String number) { // buildNumber = number; // return this; // } // // public GoBuildDetailsBuilder startedAt(DateTime startedAt) { // this.startedAt = startedAt; // return this; // } // // public GoBuildDetailsBuilder artifact(GoArtifact artifact) { // this.artifact = artifact; // return this; // } // // public GoBuildDetailsBuilder url(String buildUrl) { // this.buildUrl = buildUrl; // return this; // } // // public GoBuildDetailsBuilder envVariable(String name, String value) { // envVars.put(name, value); // return this; // } // // public GoBuildDetailsBuilder envVariables(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static <T> Matcher<T> deepEquals(T expected) { // return new DeepEqualsMatcherNoIgnores<>(expected); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static Ignored ignoring(String... ignoredFields) { // return new Ignored(ignoredFields); // }
import com.thoughtworks.go.plugin.api.task.Console; import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import com.tw.go.plugins.artifactory.GoBuildDetailsBuilder; import org.junit.Before; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.deepEquals; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.ignoring; import static java.util.Arrays.asList; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class GoBuildDetailsFactoryTest { private Map<String, String> envVars = map("GO_PIPELINE_NAME", "pipeline") .and("GO_PIPELINE_COUNTER", "pipelineCounter") .and("GO_STAGE_COUNTER", "stageCounter") .and("GO_SERVER_URL", "https://localhost:8154/go/") .and("ARTIFACTORY_PASSWORD", "passwd"); private EnvironmentVariables environment; private Console.SecureEnvVarSpecifier secureEnvSpecifier; private GoBuildDetailsFactory factory; @Before public void beforeEach() { secureEnvSpecifier = mock(Console.SecureEnvVarSpecifier.class); environment = mock(EnvironmentVariables.class); when(environment.asMap()).thenReturn(envVars); when(environment.secureEnvSpecifier()).thenReturn(secureEnvSpecifier); factory = new GoBuildDetailsFactory(); } @Test public void shouldCreateBuildDetails() { GoArtifact artifact = new GoArtifact("path", "uri/path"); GoBuildDetails details = factory.createBuildDetails(environment, asList(artifact));
// Path: src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java // public class GoBuildDetailsBuilder { // private String buildName; // private String buildNumber; // private DateTime startedAt; // private GoArtifact artifact; // private String buildUrl; // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails build() { // GoBuildDetails buildDetails = new GoBuildDetails(buildName, buildNumber, startedAt); // buildDetails.artifacts(asList(artifact)); // buildDetails.url(buildUrl); // buildDetails.environmentVariables(envVars); // // return buildDetails; // } // // public GoBuildDetailsBuilder buildName(String name) { // this.buildName = name; // return this; // } // // public GoBuildDetailsBuilder buildNumber(String number) { // buildNumber = number; // return this; // } // // public GoBuildDetailsBuilder startedAt(DateTime startedAt) { // this.startedAt = startedAt; // return this; // } // // public GoBuildDetailsBuilder artifact(GoArtifact artifact) { // this.artifact = artifact; // return this; // } // // public GoBuildDetailsBuilder url(String buildUrl) { // this.buildUrl = buildUrl; // return this; // } // // public GoBuildDetailsBuilder envVariable(String name, String value) { // envVars.put(name, value); // return this; // } // // public GoBuildDetailsBuilder envVariables(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static <T> Matcher<T> deepEquals(T expected) { // return new DeepEqualsMatcherNoIgnores<>(expected); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static Ignored ignoring(String... ignoredFields) { // return new Ignored(ignoredFields); // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactoryTest.java import com.thoughtworks.go.plugin.api.task.Console; import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import com.tw.go.plugins.artifactory.GoBuildDetailsBuilder; import org.junit.Before; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.deepEquals; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.ignoring; import static java.util.Arrays.asList; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class GoBuildDetailsFactoryTest { private Map<String, String> envVars = map("GO_PIPELINE_NAME", "pipeline") .and("GO_PIPELINE_COUNTER", "pipelineCounter") .and("GO_STAGE_COUNTER", "stageCounter") .and("GO_SERVER_URL", "https://localhost:8154/go/") .and("ARTIFACTORY_PASSWORD", "passwd"); private EnvironmentVariables environment; private Console.SecureEnvVarSpecifier secureEnvSpecifier; private GoBuildDetailsFactory factory; @Before public void beforeEach() { secureEnvSpecifier = mock(Console.SecureEnvVarSpecifier.class); environment = mock(EnvironmentVariables.class); when(environment.asMap()).thenReturn(envVars); when(environment.secureEnvSpecifier()).thenReturn(secureEnvSpecifier); factory = new GoBuildDetailsFactory(); } @Test public void shouldCreateBuildDetails() { GoArtifact artifact = new GoArtifact("path", "uri/path"); GoBuildDetails details = factory.createBuildDetails(environment, asList(artifact));
GoBuildDetails expected = new GoBuildDetailsBuilder()
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactoryTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java // public class GoBuildDetailsBuilder { // private String buildName; // private String buildNumber; // private DateTime startedAt; // private GoArtifact artifact; // private String buildUrl; // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails build() { // GoBuildDetails buildDetails = new GoBuildDetails(buildName, buildNumber, startedAt); // buildDetails.artifacts(asList(artifact)); // buildDetails.url(buildUrl); // buildDetails.environmentVariables(envVars); // // return buildDetails; // } // // public GoBuildDetailsBuilder buildName(String name) { // this.buildName = name; // return this; // } // // public GoBuildDetailsBuilder buildNumber(String number) { // buildNumber = number; // return this; // } // // public GoBuildDetailsBuilder startedAt(DateTime startedAt) { // this.startedAt = startedAt; // return this; // } // // public GoBuildDetailsBuilder artifact(GoArtifact artifact) { // this.artifact = artifact; // return this; // } // // public GoBuildDetailsBuilder url(String buildUrl) { // this.buildUrl = buildUrl; // return this; // } // // public GoBuildDetailsBuilder envVariable(String name, String value) { // envVars.put(name, value); // return this; // } // // public GoBuildDetailsBuilder envVariables(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static <T> Matcher<T> deepEquals(T expected) { // return new DeepEqualsMatcherNoIgnores<>(expected); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static Ignored ignoring(String... ignoredFields) { // return new Ignored(ignoredFields); // }
import com.thoughtworks.go.plugin.api.task.Console; import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import com.tw.go.plugins.artifactory.GoBuildDetailsBuilder; import org.junit.Before; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.deepEquals; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.ignoring; import static java.util.Arrays.asList; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class GoBuildDetailsFactoryTest { private Map<String, String> envVars = map("GO_PIPELINE_NAME", "pipeline") .and("GO_PIPELINE_COUNTER", "pipelineCounter") .and("GO_STAGE_COUNTER", "stageCounter") .and("GO_SERVER_URL", "https://localhost:8154/go/") .and("ARTIFACTORY_PASSWORD", "passwd"); private EnvironmentVariables environment; private Console.SecureEnvVarSpecifier secureEnvSpecifier; private GoBuildDetailsFactory factory; @Before public void beforeEach() { secureEnvSpecifier = mock(Console.SecureEnvVarSpecifier.class); environment = mock(EnvironmentVariables.class); when(environment.asMap()).thenReturn(envVars); when(environment.secureEnvSpecifier()).thenReturn(secureEnvSpecifier); factory = new GoBuildDetailsFactory(); } @Test public void shouldCreateBuildDetails() { GoArtifact artifact = new GoArtifact("path", "uri/path"); GoBuildDetails details = factory.createBuildDetails(environment, asList(artifact)); GoBuildDetails expected = new GoBuildDetailsBuilder() .buildName("pipeline") .buildNumber("pipelineCounter.stageCounter") .url("https://localhost:8154/go/pipelines/value_stream_map/pipeline/pipelineCounter") .artifact(artifact) .envVariables(envVars) .build();
// Path: src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java // public class GoBuildDetailsBuilder { // private String buildName; // private String buildNumber; // private DateTime startedAt; // private GoArtifact artifact; // private String buildUrl; // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails build() { // GoBuildDetails buildDetails = new GoBuildDetails(buildName, buildNumber, startedAt); // buildDetails.artifacts(asList(artifact)); // buildDetails.url(buildUrl); // buildDetails.environmentVariables(envVars); // // return buildDetails; // } // // public GoBuildDetailsBuilder buildName(String name) { // this.buildName = name; // return this; // } // // public GoBuildDetailsBuilder buildNumber(String number) { // buildNumber = number; // return this; // } // // public GoBuildDetailsBuilder startedAt(DateTime startedAt) { // this.startedAt = startedAt; // return this; // } // // public GoBuildDetailsBuilder artifact(GoArtifact artifact) { // this.artifact = artifact; // return this; // } // // public GoBuildDetailsBuilder url(String buildUrl) { // this.buildUrl = buildUrl; // return this; // } // // public GoBuildDetailsBuilder envVariable(String name, String value) { // envVars.put(name, value); // return this; // } // // public GoBuildDetailsBuilder envVariables(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static <T> Matcher<T> deepEquals(T expected) { // return new DeepEqualsMatcherNoIgnores<>(expected); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static Ignored ignoring(String... ignoredFields) { // return new Ignored(ignoredFields); // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactoryTest.java import com.thoughtworks.go.plugin.api.task.Console; import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import com.tw.go.plugins.artifactory.GoBuildDetailsBuilder; import org.junit.Before; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.deepEquals; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.ignoring; import static java.util.Arrays.asList; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class GoBuildDetailsFactoryTest { private Map<String, String> envVars = map("GO_PIPELINE_NAME", "pipeline") .and("GO_PIPELINE_COUNTER", "pipelineCounter") .and("GO_STAGE_COUNTER", "stageCounter") .and("GO_SERVER_URL", "https://localhost:8154/go/") .and("ARTIFACTORY_PASSWORD", "passwd"); private EnvironmentVariables environment; private Console.SecureEnvVarSpecifier secureEnvSpecifier; private GoBuildDetailsFactory factory; @Before public void beforeEach() { secureEnvSpecifier = mock(Console.SecureEnvVarSpecifier.class); environment = mock(EnvironmentVariables.class); when(environment.asMap()).thenReturn(envVars); when(environment.secureEnvSpecifier()).thenReturn(secureEnvSpecifier); factory = new GoBuildDetailsFactory(); } @Test public void shouldCreateBuildDetails() { GoArtifact artifact = new GoArtifact("path", "uri/path"); GoBuildDetails details = factory.createBuildDetails(environment, asList(artifact)); GoBuildDetails expected = new GoBuildDetailsBuilder() .buildName("pipeline") .buildNumber("pipelineCounter.stageCounter") .url("https://localhost:8154/go/pipelines/value_stream_map/pipeline/pipelineCounter") .artifact(artifact) .envVariables(envVars) .build();
assertThat(details, deepEquals(expected, ignoring("startedAt")));
tusharm/go-artifactory-plugin
src/test/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactoryTest.java
// Path: src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java // public class GoBuildDetailsBuilder { // private String buildName; // private String buildNumber; // private DateTime startedAt; // private GoArtifact artifact; // private String buildUrl; // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails build() { // GoBuildDetails buildDetails = new GoBuildDetails(buildName, buildNumber, startedAt); // buildDetails.artifacts(asList(artifact)); // buildDetails.url(buildUrl); // buildDetails.environmentVariables(envVars); // // return buildDetails; // } // // public GoBuildDetailsBuilder buildName(String name) { // this.buildName = name; // return this; // } // // public GoBuildDetailsBuilder buildNumber(String number) { // buildNumber = number; // return this; // } // // public GoBuildDetailsBuilder startedAt(DateTime startedAt) { // this.startedAt = startedAt; // return this; // } // // public GoBuildDetailsBuilder artifact(GoArtifact artifact) { // this.artifact = artifact; // return this; // } // // public GoBuildDetailsBuilder url(String buildUrl) { // this.buildUrl = buildUrl; // return this; // } // // public GoBuildDetailsBuilder envVariable(String name, String value) { // envVars.put(name, value); // return this; // } // // public GoBuildDetailsBuilder envVariables(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static <T> Matcher<T> deepEquals(T expected) { // return new DeepEqualsMatcherNoIgnores<>(expected); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static Ignored ignoring(String... ignoredFields) { // return new Ignored(ignoredFields); // }
import com.thoughtworks.go.plugin.api.task.Console; import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import com.tw.go.plugins.artifactory.GoBuildDetailsBuilder; import org.junit.Before; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.deepEquals; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.ignoring; import static java.util.Arrays.asList; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT;
package com.tw.go.plugins.artifactory.model; public class GoBuildDetailsFactoryTest { private Map<String, String> envVars = map("GO_PIPELINE_NAME", "pipeline") .and("GO_PIPELINE_COUNTER", "pipelineCounter") .and("GO_STAGE_COUNTER", "stageCounter") .and("GO_SERVER_URL", "https://localhost:8154/go/") .and("ARTIFACTORY_PASSWORD", "passwd"); private EnvironmentVariables environment; private Console.SecureEnvVarSpecifier secureEnvSpecifier; private GoBuildDetailsFactory factory; @Before public void beforeEach() { secureEnvSpecifier = mock(Console.SecureEnvVarSpecifier.class); environment = mock(EnvironmentVariables.class); when(environment.asMap()).thenReturn(envVars); when(environment.secureEnvSpecifier()).thenReturn(secureEnvSpecifier); factory = new GoBuildDetailsFactory(); } @Test public void shouldCreateBuildDetails() { GoArtifact artifact = new GoArtifact("path", "uri/path"); GoBuildDetails details = factory.createBuildDetails(environment, asList(artifact)); GoBuildDetails expected = new GoBuildDetailsBuilder() .buildName("pipeline") .buildNumber("pipelineCounter.stageCounter") .url("https://localhost:8154/go/pipelines/value_stream_map/pipeline/pipelineCounter") .artifact(artifact) .envVariables(envVars) .build();
// Path: src/test/java/com/tw/go/plugins/artifactory/GoBuildDetailsBuilder.java // public class GoBuildDetailsBuilder { // private String buildName; // private String buildNumber; // private DateTime startedAt; // private GoArtifact artifact; // private String buildUrl; // private Map<String, String> envVars = new HashMap<>(); // // public GoBuildDetails build() { // GoBuildDetails buildDetails = new GoBuildDetails(buildName, buildNumber, startedAt); // buildDetails.artifacts(asList(artifact)); // buildDetails.url(buildUrl); // buildDetails.environmentVariables(envVars); // // return buildDetails; // } // // public GoBuildDetailsBuilder buildName(String name) { // this.buildName = name; // return this; // } // // public GoBuildDetailsBuilder buildNumber(String number) { // buildNumber = number; // return this; // } // // public GoBuildDetailsBuilder startedAt(DateTime startedAt) { // this.startedAt = startedAt; // return this; // } // // public GoBuildDetailsBuilder artifact(GoArtifact artifact) { // this.artifact = artifact; // return this; // } // // public GoBuildDetailsBuilder url(String buildUrl) { // this.buildUrl = buildUrl; // return this; // } // // public GoBuildDetailsBuilder envVariable(String name, String value) { // envVars.put(name, value); // return this; // } // // public GoBuildDetailsBuilder envVariables(Map<String, String> envVars) { // this.envVars = envVars; // return this; // } // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/MapBuilder.java // public static <K, V> FluentMap<K, V> map(K key, V value) { // return new FluentMap<K, V>().and(key, value); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static <T> Matcher<T> deepEquals(T expected) { // return new DeepEqualsMatcherNoIgnores<>(expected); // } // // Path: src/test/java/com/tw/go/plugins/artifactory/testutils/matchers/DeepEqualsMatcher.java // public static Ignored ignoring(String... ignoredFields) { // return new Ignored(ignoredFields); // } // Path: src/test/java/com/tw/go/plugins/artifactory/model/GoBuildDetailsFactoryTest.java import com.thoughtworks.go.plugin.api.task.Console; import com.thoughtworks.go.plugin.api.task.EnvironmentVariables; import com.tw.go.plugins.artifactory.GoBuildDetailsBuilder; import org.junit.Before; import org.junit.Test; import java.util.Map; import static com.tw.go.plugins.artifactory.testutils.MapBuilder.map; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.deepEquals; import static com.tw.go.plugins.artifactory.testutils.matchers.DeepEqualsMatcher.ignoring; import static java.util.Arrays.asList; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.truth0.Truth.ASSERT; package com.tw.go.plugins.artifactory.model; public class GoBuildDetailsFactoryTest { private Map<String, String> envVars = map("GO_PIPELINE_NAME", "pipeline") .and("GO_PIPELINE_COUNTER", "pipelineCounter") .and("GO_STAGE_COUNTER", "stageCounter") .and("GO_SERVER_URL", "https://localhost:8154/go/") .and("ARTIFACTORY_PASSWORD", "passwd"); private EnvironmentVariables environment; private Console.SecureEnvVarSpecifier secureEnvSpecifier; private GoBuildDetailsFactory factory; @Before public void beforeEach() { secureEnvSpecifier = mock(Console.SecureEnvVarSpecifier.class); environment = mock(EnvironmentVariables.class); when(environment.asMap()).thenReturn(envVars); when(environment.secureEnvSpecifier()).thenReturn(secureEnvSpecifier); factory = new GoBuildDetailsFactory(); } @Test public void shouldCreateBuildDetails() { GoArtifact artifact = new GoArtifact("path", "uri/path"); GoBuildDetails details = factory.createBuildDetails(environment, asList(artifact)); GoBuildDetails expected = new GoBuildDetailsBuilder() .buildName("pipeline") .buildNumber("pipelineCounter.stageCounter") .url("https://localhost:8154/go/pipelines/value_stream_map/pipeline/pipelineCounter") .artifact(artifact) .envVariables(envVars) .build();
assertThat(details, deepEquals(expected, ignoring("startedAt")));
ARL-UTEP-OC/ecel
plugins/parsers/nmap/java/parsers/NmapDataParser.java
// Path: plugins/parsers/nmap/java/utils/FileOutput.java // public class FileOutput { // public static void WriteToFile(String filename, String content) { // try { // // File file = new File(filename); // // // if file doesnt exists, then create it // if (!file.exists()) { // file.createNewFile(); // } // // FileWriter fw = new FileWriter(file.getAbsoluteFile(), false); // BufferedWriter bw = new BufferedWriter(fw); // bw.append(content); // bw.close(); // // //System.out.println("Done writing to " + filename); // // } catch (IOException e) { // e.printStackTrace(); // } // } // }
import utils.FileOutput;
package parsers; /* * Uses https://github.com/stleary/JSON-java repository to convert xml nmap output file to its JSON representation. * * As of now, the nmap command that generates the xml file is 'nmap -sP -oX {output_file_path} 10.0.0.0/24'. * This returns a list of 'hosts' that were scanned for that ip range. * XMLToJSON builder will create an array of JSON objects with information about those hosts. * The format being: * [ { * "nmap_id": ID of current obj, * "start": start time of command, * "className": name of command, * "content": host information (address, address type, status...) * }, * ..... * ] * The format of the json follows that seen in the other collectors parsed json files. * If for any reason an there was an error thrown while parsing host data, the application will instead just output the raw json it * receieved from the output xml file. * Returns an array of json objects */ public class NmapDataParser { private static final String ERROR_JSON = "{\"exception_message\":"; private static String xmlFilePath; private static String outputFilePath; private static XMLToJSONBuilder json; public static void main(String[] args) { if(args.length != 2) { System.out.println("Argument error."); System.out.println("Usage: java -jar xmlFilePath outputFilePath"); return; } xmlFilePath = args[0]; outputFilePath = args[1]; try { System.out.println("Converting nmap xml file to JSON object..."); json = new XMLToJSONBuilder(xmlFilePath); System.out.println("Writing json data to output file " + outputFilePath + "...");
// Path: plugins/parsers/nmap/java/utils/FileOutput.java // public class FileOutput { // public static void WriteToFile(String filename, String content) { // try { // // File file = new File(filename); // // // if file doesnt exists, then create it // if (!file.exists()) { // file.createNewFile(); // } // // FileWriter fw = new FileWriter(file.getAbsoluteFile(), false); // BufferedWriter bw = new BufferedWriter(fw); // bw.append(content); // bw.close(); // // //System.out.println("Done writing to " + filename); // // } catch (IOException e) { // e.printStackTrace(); // } // } // } // Path: plugins/parsers/nmap/java/parsers/NmapDataParser.java import utils.FileOutput; package parsers; /* * Uses https://github.com/stleary/JSON-java repository to convert xml nmap output file to its JSON representation. * * As of now, the nmap command that generates the xml file is 'nmap -sP -oX {output_file_path} 10.0.0.0/24'. * This returns a list of 'hosts' that were scanned for that ip range. * XMLToJSON builder will create an array of JSON objects with information about those hosts. * The format being: * [ { * "nmap_id": ID of current obj, * "start": start time of command, * "className": name of command, * "content": host information (address, address type, status...) * }, * ..... * ] * The format of the json follows that seen in the other collectors parsed json files. * If for any reason an there was an error thrown while parsing host data, the application will instead just output the raw json it * receieved from the output xml file. * Returns an array of json objects */ public class NmapDataParser { private static final String ERROR_JSON = "{\"exception_message\":"; private static String xmlFilePath; private static String outputFilePath; private static XMLToJSONBuilder json; public static void main(String[] args) { if(args.length != 2) { System.out.println("Argument error."); System.out.println("Usage: java -jar xmlFilePath outputFilePath"); return; } xmlFilePath = args[0]; outputFilePath = args[1]; try { System.out.println("Converting nmap xml file to JSON object..."); json = new XMLToJSONBuilder(xmlFilePath); System.out.println("Writing json data to output file " + outputFilePath + "...");
FileOutput.WriteToFile(outputFilePath, json.getNmapJSON());
evanwong/hipchat-java
src/test/groovy/io/evanwong/oss/hipchat/v2/PojoTest.java
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/EmoticonItem.java // public class EmoticonItem { // // private String url; // private Links links; // private String id; // private String shortcut; // private EmoticonType type; // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public Links getLinks() { // return links; // } // // public void setLinks(Links links) { // this.links = links; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getShortcut() { // return shortcut; // } // // public void setShortcut(String shortcut) { // this.shortcut = shortcut; // } // // public EmoticonType getType() { // return type; // } // // public void setType(EmoticonType type) { // this.type = type; // } // }
import com.openpojo.reflection.impl.PojoClassFactory; import com.openpojo.validation.*; import com.openpojo.validation.rule.impl.*; import com.openpojo.validation.test.impl.*; import io.evanwong.oss.hipchat.v2.emoticons.EmoticonItem; import io.evanwong.oss.hipchat.v2.emoticons.Emoticons; import io.evanwong.oss.hipchat.v2.rooms.Owner; import io.evanwong.oss.hipchat.v2.rooms.Room; import io.evanwong.oss.hipchat.v2.rooms.RoomItem; import io.evanwong.oss.hipchat.v2.rooms.Rooms; import io.evanwong.oss.hipchat.v2.users.*; import org.junit.Test;
package io.evanwong.oss.hipchat.v2; public class PojoTest { @Test public void testPojoStructureAndBehavior() { Validator validator = ValidatorBuilder.create() .with(new GetterMustExistRule()) .with(new SetterMustExistRule()) .with(new SetterTester()) .with(new GetterTester()) .build(); validator.validate(PojoClassFactory.getPojoClass(UserItem.class)); validator.validate(PojoClassFactory.getPojoClass(Users.class)); validator.validate(PojoClassFactory.getPojoClass(Owner.class)); validator.validate(PojoClassFactory.getPojoClass(Room.class)); validator.validate(PojoClassFactory.getPojoClass(Rooms.class)); validator.validate(PojoClassFactory.getPojoClass(RoomItem.class)); validator.validate(PojoClassFactory.getPojoClass(Emoticons.class));
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/EmoticonItem.java // public class EmoticonItem { // // private String url; // private Links links; // private String id; // private String shortcut; // private EmoticonType type; // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public Links getLinks() { // return links; // } // // public void setLinks(Links links) { // this.links = links; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getShortcut() { // return shortcut; // } // // public void setShortcut(String shortcut) { // this.shortcut = shortcut; // } // // public EmoticonType getType() { // return type; // } // // public void setType(EmoticonType type) { // this.type = type; // } // } // Path: src/test/groovy/io/evanwong/oss/hipchat/v2/PojoTest.java import com.openpojo.reflection.impl.PojoClassFactory; import com.openpojo.validation.*; import com.openpojo.validation.rule.impl.*; import com.openpojo.validation.test.impl.*; import io.evanwong.oss.hipchat.v2.emoticons.EmoticonItem; import io.evanwong.oss.hipchat.v2.emoticons.Emoticons; import io.evanwong.oss.hipchat.v2.rooms.Owner; import io.evanwong.oss.hipchat.v2.rooms.Room; import io.evanwong.oss.hipchat.v2.rooms.RoomItem; import io.evanwong.oss.hipchat.v2.rooms.Rooms; import io.evanwong.oss.hipchat.v2.users.*; import org.junit.Test; package io.evanwong.oss.hipchat.v2; public class PojoTest { @Test public void testPojoStructureAndBehavior() { Validator validator = ValidatorBuilder.create() .with(new GetterMustExistRule()) .with(new SetterMustExistRule()) .with(new SetterTester()) .with(new GetterTester()) .build(); validator.validate(PojoClassFactory.getPojoClass(UserItem.class)); validator.validate(PojoClassFactory.getPojoClass(Users.class)); validator.validate(PojoClassFactory.getPojoClass(Owner.class)); validator.validate(PojoClassFactory.getPojoClass(Room.class)); validator.validate(PojoClassFactory.getPojoClass(Rooms.class)); validator.validate(PojoClassFactory.getPojoClass(RoomItem.class)); validator.validate(PojoClassFactory.getPojoClass(Emoticons.class));
validator.validate(PojoClassFactory.getPojoClass(EmoticonItem.class));
evanwong/hipchat-java
src/main/java/io/evanwong/oss/hipchat/v2/HipChatClient.java
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetAllEmoticonsRequestBuilder.java // public class GetAllEmoticonsRequestBuilder extends ExpandableRequestBuilder<GetAllEmoticonsRequestBuilder, GetAllEmoticonsRequest> { // // private Integer startIndex; // private Integer maxResults; // private EmoticonType type; // // public GetAllEmoticonsRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // public Integer getStartIndex() { // return startIndex; // } // // public GetAllEmoticonsRequestBuilder setStartIndex(Integer startIndex) { // this.startIndex = startIndex; // return this; // } // // public Integer getMaxResults() { // return maxResults; // } // // public GetAllEmoticonsRequestBuilder setMaxResults(Integer maxResults) { // this.maxResults = maxResults; // return this; // } // // public EmoticonType getType() { // return type; // } // // public GetAllEmoticonsRequestBuilder setType(EmoticonType type) { // this.type = type; // return this; // } // // @Override // public GetAllEmoticonsRequest build() { // return new GetAllEmoticonsRequest(startIndex, maxResults, type, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetEmoticonRequestBuilder.java // public class GetEmoticonRequestBuilder extends RequestBuilder<GetEmoticonRequest> { // // private final String idOrShortcut; // // public GetEmoticonRequestBuilder(String idOrShortcut, String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // this.idOrShortcut = idOrShortcut; // } // // public String getIdOrShortcut() { // return idOrShortcut; // } // // @Override // public GetEmoticonRequest build() { // return new GetEmoticonRequest(idOrShortcut, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/oauth/GetSessionRequestBuilder.java // public class GetSessionRequestBuilder extends ExpandableRequestBuilder<GetSessionRequestBuilder, GetSessionRequest> { // // // public GetSessionRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // @Override // public GetSessionRequest build() { // if (accessToken == null) { // throw new IllegalArgumentException("accessToken is required"); // } // return new GetSessionRequest(accessToken, baseUrl, httpClient, executorService); // } // }
import io.evanwong.oss.hipchat.v2.emoticons.GetAllEmoticonsRequestBuilder; import io.evanwong.oss.hipchat.v2.emoticons.GetEmoticonRequestBuilder; import io.evanwong.oss.hipchat.v2.oauth.GetSessionRequestBuilder; import io.evanwong.oss.hipchat.v2.rooms.*; import io.evanwong.oss.hipchat.v2.users.*; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;
} public SendRoomMessageRequestBuilder prepareSendRoomMessageRequestBuilder(String idOrName, String message) { return prepareSendRoomMessageRequestBuilder(idOrName, message, defaultAccessToken); } public SendRoomNotificationRequestBuilder prepareSendRoomNotificationRequestBuilder(String idOrName, String message, String accessToken) { return new SendRoomNotificationRequestBuilder(idOrName, message, accessToken, baseUrl, httpClient, executorService); } public SendRoomNotificationRequestBuilder prepareSendRoomNotificationRequestBuilder(String idOrName, String message) { return prepareSendRoomNotificationRequestBuilder(idOrName, message, defaultAccessToken); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name, String accessToken) { return new CreateRoomRequestBuilder(name, accessToken, baseUrl, httpClient, executorService); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name) { return prepareCreateRoomRequestBuilder(name, defaultAccessToken); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName, String accessToken) { return new GetRoomRequestBuilder(idOrName, accessToken, baseUrl, httpClient, executorService); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName) { return prepareGetRoomRequestBuilder(idOrName, defaultAccessToken); }
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetAllEmoticonsRequestBuilder.java // public class GetAllEmoticonsRequestBuilder extends ExpandableRequestBuilder<GetAllEmoticonsRequestBuilder, GetAllEmoticonsRequest> { // // private Integer startIndex; // private Integer maxResults; // private EmoticonType type; // // public GetAllEmoticonsRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // public Integer getStartIndex() { // return startIndex; // } // // public GetAllEmoticonsRequestBuilder setStartIndex(Integer startIndex) { // this.startIndex = startIndex; // return this; // } // // public Integer getMaxResults() { // return maxResults; // } // // public GetAllEmoticonsRequestBuilder setMaxResults(Integer maxResults) { // this.maxResults = maxResults; // return this; // } // // public EmoticonType getType() { // return type; // } // // public GetAllEmoticonsRequestBuilder setType(EmoticonType type) { // this.type = type; // return this; // } // // @Override // public GetAllEmoticonsRequest build() { // return new GetAllEmoticonsRequest(startIndex, maxResults, type, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetEmoticonRequestBuilder.java // public class GetEmoticonRequestBuilder extends RequestBuilder<GetEmoticonRequest> { // // private final String idOrShortcut; // // public GetEmoticonRequestBuilder(String idOrShortcut, String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // this.idOrShortcut = idOrShortcut; // } // // public String getIdOrShortcut() { // return idOrShortcut; // } // // @Override // public GetEmoticonRequest build() { // return new GetEmoticonRequest(idOrShortcut, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/oauth/GetSessionRequestBuilder.java // public class GetSessionRequestBuilder extends ExpandableRequestBuilder<GetSessionRequestBuilder, GetSessionRequest> { // // // public GetSessionRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // @Override // public GetSessionRequest build() { // if (accessToken == null) { // throw new IllegalArgumentException("accessToken is required"); // } // return new GetSessionRequest(accessToken, baseUrl, httpClient, executorService); // } // } // Path: src/main/java/io/evanwong/oss/hipchat/v2/HipChatClient.java import io.evanwong.oss.hipchat.v2.emoticons.GetAllEmoticonsRequestBuilder; import io.evanwong.oss.hipchat.v2.emoticons.GetEmoticonRequestBuilder; import io.evanwong.oss.hipchat.v2.oauth.GetSessionRequestBuilder; import io.evanwong.oss.hipchat.v2.rooms.*; import io.evanwong.oss.hipchat.v2.users.*; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; } public SendRoomMessageRequestBuilder prepareSendRoomMessageRequestBuilder(String idOrName, String message) { return prepareSendRoomMessageRequestBuilder(idOrName, message, defaultAccessToken); } public SendRoomNotificationRequestBuilder prepareSendRoomNotificationRequestBuilder(String idOrName, String message, String accessToken) { return new SendRoomNotificationRequestBuilder(idOrName, message, accessToken, baseUrl, httpClient, executorService); } public SendRoomNotificationRequestBuilder prepareSendRoomNotificationRequestBuilder(String idOrName, String message) { return prepareSendRoomNotificationRequestBuilder(idOrName, message, defaultAccessToken); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name, String accessToken) { return new CreateRoomRequestBuilder(name, accessToken, baseUrl, httpClient, executorService); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name) { return prepareCreateRoomRequestBuilder(name, defaultAccessToken); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName, String accessToken) { return new GetRoomRequestBuilder(idOrName, accessToken, baseUrl, httpClient, executorService); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName) { return prepareGetRoomRequestBuilder(idOrName, defaultAccessToken); }
public GetEmoticonRequestBuilder prepareGetEmoticonRequestBuilder(String idOrShortcut) {
evanwong/hipchat-java
src/main/java/io/evanwong/oss/hipchat/v2/HipChatClient.java
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetAllEmoticonsRequestBuilder.java // public class GetAllEmoticonsRequestBuilder extends ExpandableRequestBuilder<GetAllEmoticonsRequestBuilder, GetAllEmoticonsRequest> { // // private Integer startIndex; // private Integer maxResults; // private EmoticonType type; // // public GetAllEmoticonsRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // public Integer getStartIndex() { // return startIndex; // } // // public GetAllEmoticonsRequestBuilder setStartIndex(Integer startIndex) { // this.startIndex = startIndex; // return this; // } // // public Integer getMaxResults() { // return maxResults; // } // // public GetAllEmoticonsRequestBuilder setMaxResults(Integer maxResults) { // this.maxResults = maxResults; // return this; // } // // public EmoticonType getType() { // return type; // } // // public GetAllEmoticonsRequestBuilder setType(EmoticonType type) { // this.type = type; // return this; // } // // @Override // public GetAllEmoticonsRequest build() { // return new GetAllEmoticonsRequest(startIndex, maxResults, type, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetEmoticonRequestBuilder.java // public class GetEmoticonRequestBuilder extends RequestBuilder<GetEmoticonRequest> { // // private final String idOrShortcut; // // public GetEmoticonRequestBuilder(String idOrShortcut, String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // this.idOrShortcut = idOrShortcut; // } // // public String getIdOrShortcut() { // return idOrShortcut; // } // // @Override // public GetEmoticonRequest build() { // return new GetEmoticonRequest(idOrShortcut, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/oauth/GetSessionRequestBuilder.java // public class GetSessionRequestBuilder extends ExpandableRequestBuilder<GetSessionRequestBuilder, GetSessionRequest> { // // // public GetSessionRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // @Override // public GetSessionRequest build() { // if (accessToken == null) { // throw new IllegalArgumentException("accessToken is required"); // } // return new GetSessionRequest(accessToken, baseUrl, httpClient, executorService); // } // }
import io.evanwong.oss.hipchat.v2.emoticons.GetAllEmoticonsRequestBuilder; import io.evanwong.oss.hipchat.v2.emoticons.GetEmoticonRequestBuilder; import io.evanwong.oss.hipchat.v2.oauth.GetSessionRequestBuilder; import io.evanwong.oss.hipchat.v2.rooms.*; import io.evanwong.oss.hipchat.v2.users.*; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;
} public SendRoomNotificationRequestBuilder prepareSendRoomNotificationRequestBuilder(String idOrName, String message) { return prepareSendRoomNotificationRequestBuilder(idOrName, message, defaultAccessToken); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name, String accessToken) { return new CreateRoomRequestBuilder(name, accessToken, baseUrl, httpClient, executorService); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name) { return prepareCreateRoomRequestBuilder(name, defaultAccessToken); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName, String accessToken) { return new GetRoomRequestBuilder(idOrName, accessToken, baseUrl, httpClient, executorService); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName) { return prepareGetRoomRequestBuilder(idOrName, defaultAccessToken); } public GetEmoticonRequestBuilder prepareGetEmoticonRequestBuilder(String idOrShortcut) { return prepareGetEmoticonRequestBuilder(idOrShortcut, defaultAccessToken); } public GetEmoticonRequestBuilder prepareGetEmoticonRequestBuilder(String idOrShortcut, String accessToken) { return new GetEmoticonRequestBuilder(idOrShortcut, accessToken, baseUrl, httpClient, executorService); }
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetAllEmoticonsRequestBuilder.java // public class GetAllEmoticonsRequestBuilder extends ExpandableRequestBuilder<GetAllEmoticonsRequestBuilder, GetAllEmoticonsRequest> { // // private Integer startIndex; // private Integer maxResults; // private EmoticonType type; // // public GetAllEmoticonsRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // public Integer getStartIndex() { // return startIndex; // } // // public GetAllEmoticonsRequestBuilder setStartIndex(Integer startIndex) { // this.startIndex = startIndex; // return this; // } // // public Integer getMaxResults() { // return maxResults; // } // // public GetAllEmoticonsRequestBuilder setMaxResults(Integer maxResults) { // this.maxResults = maxResults; // return this; // } // // public EmoticonType getType() { // return type; // } // // public GetAllEmoticonsRequestBuilder setType(EmoticonType type) { // this.type = type; // return this; // } // // @Override // public GetAllEmoticonsRequest build() { // return new GetAllEmoticonsRequest(startIndex, maxResults, type, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetEmoticonRequestBuilder.java // public class GetEmoticonRequestBuilder extends RequestBuilder<GetEmoticonRequest> { // // private final String idOrShortcut; // // public GetEmoticonRequestBuilder(String idOrShortcut, String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // this.idOrShortcut = idOrShortcut; // } // // public String getIdOrShortcut() { // return idOrShortcut; // } // // @Override // public GetEmoticonRequest build() { // return new GetEmoticonRequest(idOrShortcut, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/oauth/GetSessionRequestBuilder.java // public class GetSessionRequestBuilder extends ExpandableRequestBuilder<GetSessionRequestBuilder, GetSessionRequest> { // // // public GetSessionRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // @Override // public GetSessionRequest build() { // if (accessToken == null) { // throw new IllegalArgumentException("accessToken is required"); // } // return new GetSessionRequest(accessToken, baseUrl, httpClient, executorService); // } // } // Path: src/main/java/io/evanwong/oss/hipchat/v2/HipChatClient.java import io.evanwong.oss.hipchat.v2.emoticons.GetAllEmoticonsRequestBuilder; import io.evanwong.oss.hipchat.v2.emoticons.GetEmoticonRequestBuilder; import io.evanwong.oss.hipchat.v2.oauth.GetSessionRequestBuilder; import io.evanwong.oss.hipchat.v2.rooms.*; import io.evanwong.oss.hipchat.v2.users.*; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; } public SendRoomNotificationRequestBuilder prepareSendRoomNotificationRequestBuilder(String idOrName, String message) { return prepareSendRoomNotificationRequestBuilder(idOrName, message, defaultAccessToken); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name, String accessToken) { return new CreateRoomRequestBuilder(name, accessToken, baseUrl, httpClient, executorService); } public CreateRoomRequestBuilder prepareCreateRoomRequestBuilder(String name) { return prepareCreateRoomRequestBuilder(name, defaultAccessToken); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName, String accessToken) { return new GetRoomRequestBuilder(idOrName, accessToken, baseUrl, httpClient, executorService); } public GetRoomRequestBuilder prepareGetRoomRequestBuilder(String idOrName) { return prepareGetRoomRequestBuilder(idOrName, defaultAccessToken); } public GetEmoticonRequestBuilder prepareGetEmoticonRequestBuilder(String idOrShortcut) { return prepareGetEmoticonRequestBuilder(idOrShortcut, defaultAccessToken); } public GetEmoticonRequestBuilder prepareGetEmoticonRequestBuilder(String idOrShortcut, String accessToken) { return new GetEmoticonRequestBuilder(idOrShortcut, accessToken, baseUrl, httpClient, executorService); }
public GetAllEmoticonsRequestBuilder prepareGetAllEmoticonsRequestBuilder() {
evanwong/hipchat-java
src/main/java/io/evanwong/oss/hipchat/v2/HipChatClient.java
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetAllEmoticonsRequestBuilder.java // public class GetAllEmoticonsRequestBuilder extends ExpandableRequestBuilder<GetAllEmoticonsRequestBuilder, GetAllEmoticonsRequest> { // // private Integer startIndex; // private Integer maxResults; // private EmoticonType type; // // public GetAllEmoticonsRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // public Integer getStartIndex() { // return startIndex; // } // // public GetAllEmoticonsRequestBuilder setStartIndex(Integer startIndex) { // this.startIndex = startIndex; // return this; // } // // public Integer getMaxResults() { // return maxResults; // } // // public GetAllEmoticonsRequestBuilder setMaxResults(Integer maxResults) { // this.maxResults = maxResults; // return this; // } // // public EmoticonType getType() { // return type; // } // // public GetAllEmoticonsRequestBuilder setType(EmoticonType type) { // this.type = type; // return this; // } // // @Override // public GetAllEmoticonsRequest build() { // return new GetAllEmoticonsRequest(startIndex, maxResults, type, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetEmoticonRequestBuilder.java // public class GetEmoticonRequestBuilder extends RequestBuilder<GetEmoticonRequest> { // // private final String idOrShortcut; // // public GetEmoticonRequestBuilder(String idOrShortcut, String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // this.idOrShortcut = idOrShortcut; // } // // public String getIdOrShortcut() { // return idOrShortcut; // } // // @Override // public GetEmoticonRequest build() { // return new GetEmoticonRequest(idOrShortcut, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/oauth/GetSessionRequestBuilder.java // public class GetSessionRequestBuilder extends ExpandableRequestBuilder<GetSessionRequestBuilder, GetSessionRequest> { // // // public GetSessionRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // @Override // public GetSessionRequest build() { // if (accessToken == null) { // throw new IllegalArgumentException("accessToken is required"); // } // return new GetSessionRequest(accessToken, baseUrl, httpClient, executorService); // } // }
import io.evanwong.oss.hipchat.v2.emoticons.GetAllEmoticonsRequestBuilder; import io.evanwong.oss.hipchat.v2.emoticons.GetEmoticonRequestBuilder; import io.evanwong.oss.hipchat.v2.oauth.GetSessionRequestBuilder; import io.evanwong.oss.hipchat.v2.rooms.*; import io.evanwong.oss.hipchat.v2.users.*; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors;
public ViewUserRequestBuilder prepareViewUserRequestBuilder(String idOrEmail) { return prepareViewUserRequestBuilder(idOrEmail, defaultAccessToken); } private DeleteUserRequestBuilder prepareDeleteUserRequestBuilder(String idOrEmail, String accessToken) { return new DeleteUserRequestBuilder(idOrEmail, accessToken, baseUrl, httpClient, executorService); } public DeleteUserRequestBuilder prepareDeleteUserRequestBuilder(String idOrEmail) { return prepareDeleteUserRequestBuilder(idOrEmail, defaultAccessToken); } public PrivateMessageUserRequestBuilder preparePrivateMessageUserRequestBuilder(String idOrEmail, String message) { return preparePrivateMessageUserRequestBuilder(idOrEmail, message, defaultAccessToken); } public PrivateMessageUserRequestBuilder preparePrivateMessageUserRequestBuilder(String idOrEmail, String message, String accessToken) { return new PrivateMessageUserRequestBuilder(idOrEmail, message, accessToken, baseUrl, httpClient, executorService); } public void close() { log.info("Shutting down..."); try { httpClient.close(); } catch (IOException e) { log.error("Failed to close the HttpClient.", e); } executorService.shutdown(); }
// Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetAllEmoticonsRequestBuilder.java // public class GetAllEmoticonsRequestBuilder extends ExpandableRequestBuilder<GetAllEmoticonsRequestBuilder, GetAllEmoticonsRequest> { // // private Integer startIndex; // private Integer maxResults; // private EmoticonType type; // // public GetAllEmoticonsRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // public Integer getStartIndex() { // return startIndex; // } // // public GetAllEmoticonsRequestBuilder setStartIndex(Integer startIndex) { // this.startIndex = startIndex; // return this; // } // // public Integer getMaxResults() { // return maxResults; // } // // public GetAllEmoticonsRequestBuilder setMaxResults(Integer maxResults) { // this.maxResults = maxResults; // return this; // } // // public EmoticonType getType() { // return type; // } // // public GetAllEmoticonsRequestBuilder setType(EmoticonType type) { // this.type = type; // return this; // } // // @Override // public GetAllEmoticonsRequest build() { // return new GetAllEmoticonsRequest(startIndex, maxResults, type, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/emoticons/GetEmoticonRequestBuilder.java // public class GetEmoticonRequestBuilder extends RequestBuilder<GetEmoticonRequest> { // // private final String idOrShortcut; // // public GetEmoticonRequestBuilder(String idOrShortcut, String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // this.idOrShortcut = idOrShortcut; // } // // public String getIdOrShortcut() { // return idOrShortcut; // } // // @Override // public GetEmoticonRequest build() { // return new GetEmoticonRequest(idOrShortcut, accessToken, baseUrl, httpClient, executorService); // } // } // // Path: src/main/java/io/evanwong/oss/hipchat/v2/oauth/GetSessionRequestBuilder.java // public class GetSessionRequestBuilder extends ExpandableRequestBuilder<GetSessionRequestBuilder, GetSessionRequest> { // // // public GetSessionRequestBuilder(String accessToken, String baseUrl, HttpClient httpClient, ExecutorService executorService) { // super(accessToken, baseUrl, httpClient, executorService); // } // // @Override // public GetSessionRequest build() { // if (accessToken == null) { // throw new IllegalArgumentException("accessToken is required"); // } // return new GetSessionRequest(accessToken, baseUrl, httpClient, executorService); // } // } // Path: src/main/java/io/evanwong/oss/hipchat/v2/HipChatClient.java import io.evanwong.oss.hipchat.v2.emoticons.GetAllEmoticonsRequestBuilder; import io.evanwong.oss.hipchat.v2.emoticons.GetEmoticonRequestBuilder; import io.evanwong.oss.hipchat.v2.oauth.GetSessionRequestBuilder; import io.evanwong.oss.hipchat.v2.rooms.*; import io.evanwong.oss.hipchat.v2.users.*; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public ViewUserRequestBuilder prepareViewUserRequestBuilder(String idOrEmail) { return prepareViewUserRequestBuilder(idOrEmail, defaultAccessToken); } private DeleteUserRequestBuilder prepareDeleteUserRequestBuilder(String idOrEmail, String accessToken) { return new DeleteUserRequestBuilder(idOrEmail, accessToken, baseUrl, httpClient, executorService); } public DeleteUserRequestBuilder prepareDeleteUserRequestBuilder(String idOrEmail) { return prepareDeleteUserRequestBuilder(idOrEmail, defaultAccessToken); } public PrivateMessageUserRequestBuilder preparePrivateMessageUserRequestBuilder(String idOrEmail, String message) { return preparePrivateMessageUserRequestBuilder(idOrEmail, message, defaultAccessToken); } public PrivateMessageUserRequestBuilder preparePrivateMessageUserRequestBuilder(String idOrEmail, String message, String accessToken) { return new PrivateMessageUserRequestBuilder(idOrEmail, message, accessToken, baseUrl, httpClient, executorService); } public void close() { log.info("Shutting down..."); try { httpClient.close(); } catch (IOException e) { log.error("Failed to close the HttpClient.", e); } executorService.shutdown(); }
public GetSessionRequestBuilder prepareGetSessionRequestBuilder() {
Nuvoex/async-file-uploader
fileuploader/src/main/java/com/nuvoex/fileuploader/UploadBroadcastReceiver.java
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/utils/Constants.java // public class Constants { // // /** // * Configuration values. // */ // public final class Configs { // // /** // * Timeout for file upload requests in seconds. // */ // public static final int TIMEOUT = 60; // } // // public final class Urls { // // // dummy value, not used for uploads // public static final String BASE_URL = "https://nuvoex.com"; // } // // /** // * Keys for extra data. // */ // public final class Keys { // // public static final String EXTRA_FILE_PATH = "com.nuvoex.fileuploader.FILE_LOCAL_PATH"; // // public static final String EXTRA_UPLOAD_URL = "com.nuvoex.fileuploader.FILE_UPLOAD_URL"; // // public static final String EXTRA_DELETE_ON_UPLOAD = "com.nuvoex.fileuploader.DELETE_ON_UPLOAD"; // // public static final String EXTRA_EXTRAS = "com.nuvoex.fileuploader.EXTRAS"; // // public static final String EXTRA_UPLOAD_STATUS = "com.nuvoex.fileuploader.FILE_UPLOAD_STATUS"; // // public static final String EXTRA_UPLOAD_ERROR = "com.nuvoex.fileuploader.FILE_UPLOAD_ERROR"; // } // // /** // * Actions broadcast by upload service. // * Receivers can be declared in the manifest to respond to these broadcasts. // */ // public final class Actions { // // /** // * Broadcast action sent whenever a file upload status changes. // * @see Status List of possible status values // */ // public static final String STATUS_CHANGE = "com.nuvoex.fileuploader.ACTION_STATUS_CHANGE"; // } // // /** // * Status associated with each file upload event. // */ // public final class Status { // // /** // * File upload has started. // */ // public static final int STARTED = 1; // // /** // * File upload failed. It will be automatically retried. // */ // public static final int FAILED = 2; // // /** // * File upload completed. // */ // public static final int COMPLETED = 3; // // /** // * File upload was cancelled. It will not be retried. // */ // public static final int CANCELLED = 4; // } // // public static final String TAG = "FILE_UPLOAD"; // }
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import com.nuvoex.fileuploader.utils.Constants; import java.util.Map;
package com.nuvoex.fileuploader; /** * Created by dilip on 11/01/17. */ /** * A {@link BroadcastReceiver} that receives file upload actions and calls the appropriate methods. * Applications should implement the abstract methods for responding to various upload events. * This {@link BroadcastReceiver} must be registered in the manifest with the proper intent filter. * <pre> * {@code * <receiver android:name=".UploadBroadcastReceiverSubclass"> * <intent-filter> * <action android:name="com.nuvoex.fileuploader.ACTION_STATUS_CHANGE" /> * <category android:name="app.package.name.CATEGORY_UPLOAD" /> * </intent-filter> * </receiver> * } * </pre> * Replace app.package.name with the correct application package name. */ public abstract class UploadBroadcastReceiver extends BroadcastReceiver { /** * Delegates the generic {@code onReceive} event to a file upload event. Subclasses should override * the event methods and not this method. * @param context The context in which the receiver is running. * @param intent An {@code Intent} containing data about the file upload. */ @Override public void onReceive(Context context, Intent intent) {
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/utils/Constants.java // public class Constants { // // /** // * Configuration values. // */ // public final class Configs { // // /** // * Timeout for file upload requests in seconds. // */ // public static final int TIMEOUT = 60; // } // // public final class Urls { // // // dummy value, not used for uploads // public static final String BASE_URL = "https://nuvoex.com"; // } // // /** // * Keys for extra data. // */ // public final class Keys { // // public static final String EXTRA_FILE_PATH = "com.nuvoex.fileuploader.FILE_LOCAL_PATH"; // // public static final String EXTRA_UPLOAD_URL = "com.nuvoex.fileuploader.FILE_UPLOAD_URL"; // // public static final String EXTRA_DELETE_ON_UPLOAD = "com.nuvoex.fileuploader.DELETE_ON_UPLOAD"; // // public static final String EXTRA_EXTRAS = "com.nuvoex.fileuploader.EXTRAS"; // // public static final String EXTRA_UPLOAD_STATUS = "com.nuvoex.fileuploader.FILE_UPLOAD_STATUS"; // // public static final String EXTRA_UPLOAD_ERROR = "com.nuvoex.fileuploader.FILE_UPLOAD_ERROR"; // } // // /** // * Actions broadcast by upload service. // * Receivers can be declared in the manifest to respond to these broadcasts. // */ // public final class Actions { // // /** // * Broadcast action sent whenever a file upload status changes. // * @see Status List of possible status values // */ // public static final String STATUS_CHANGE = "com.nuvoex.fileuploader.ACTION_STATUS_CHANGE"; // } // // /** // * Status associated with each file upload event. // */ // public final class Status { // // /** // * File upload has started. // */ // public static final int STARTED = 1; // // /** // * File upload failed. It will be automatically retried. // */ // public static final int FAILED = 2; // // /** // * File upload completed. // */ // public static final int COMPLETED = 3; // // /** // * File upload was cancelled. It will not be retried. // */ // public static final int CANCELLED = 4; // } // // public static final String TAG = "FILE_UPLOAD"; // } // Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadBroadcastReceiver.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import com.nuvoex.fileuploader.utils.Constants; import java.util.Map; package com.nuvoex.fileuploader; /** * Created by dilip on 11/01/17. */ /** * A {@link BroadcastReceiver} that receives file upload actions and calls the appropriate methods. * Applications should implement the abstract methods for responding to various upload events. * This {@link BroadcastReceiver} must be registered in the manifest with the proper intent filter. * <pre> * {@code * <receiver android:name=".UploadBroadcastReceiverSubclass"> * <intent-filter> * <action android:name="com.nuvoex.fileuploader.ACTION_STATUS_CHANGE" /> * <category android:name="app.package.name.CATEGORY_UPLOAD" /> * </intent-filter> * </receiver> * } * </pre> * Replace app.package.name with the correct application package name. */ public abstract class UploadBroadcastReceiver extends BroadcastReceiver { /** * Delegates the generic {@code onReceive} event to a file upload event. Subclasses should override * the event methods and not this method. * @param context The context in which the receiver is running. * @param intent An {@code Intent} containing data about the file upload. */ @Override public void onReceive(Context context, Intent intent) {
if (intent == null || !intent.hasExtra(Constants.Keys.EXTRA_UPLOAD_STATUS) || !intent.hasExtra(Intent.EXTRA_UID)) {
Nuvoex/async-file-uploader
sample/src/main/java/com/nuvoex/fileuploadersample/UploadReceiver.java
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadBroadcastReceiver.java // public abstract class UploadBroadcastReceiver extends BroadcastReceiver { // // /** // * Delegates the generic {@code onReceive} event to a file upload event. Subclasses should override // * the event methods and not this method. // * @param context The context in which the receiver is running. // * @param intent An {@code Intent} containing data about the file upload. // */ // @Override // public void onReceive(Context context, Intent intent) { // if (intent == null || !intent.hasExtra(Constants.Keys.EXTRA_UPLOAD_STATUS) || !intent.hasExtra(Intent.EXTRA_UID)) { // return; // } // // String uploadId = intent.getStringExtra(Intent.EXTRA_UID); // Map<String, String> extras = (Map<String, String>) intent.getSerializableExtra(Constants.Keys.EXTRA_EXTRAS); // // switch (intent.getIntExtra(Constants.Keys.EXTRA_UPLOAD_STATUS, 0)) { // case Constants.Status.STARTED: // onStart(context, uploadId, extras); // break; // case Constants.Status.FAILED: // onFail(context, uploadId, extras, (UploadError) intent.getSerializableExtra(Constants.Keys.EXTRA_UPLOAD_ERROR)); // break; // case Constants.Status.COMPLETED: // onComplete(context, uploadId, extras); // break; // case Constants.Status.CANCELLED: // onCancel(context, uploadId, extras); // break; // } // } // // /** // * Called when a file upload begins. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // */ // public abstract void onStart(Context context, String uploadId, Map<String, String> extras); // // /** // * Called when a file upload fails. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // * @param error {@link UploadError} with details of the failure. // */ // public abstract void onFail(Context context, String uploadId, Map<String, String> extras, UploadError error); // // /** // * Called when a file upload is completed. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // */ // public abstract void onComplete(Context context, String uploadId, Map<String, String> extras); // // /** // * Called when a file upload is cancelled. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // */ // public abstract void onCancel(Context context, String uploadId, Map<String, String> extras); // } // // Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadError.java // public class UploadError implements Serializable { // // /** // * Error type for client or server errors. // */ // public static final int ERROR_RESPONSE = 1; // // /** // * Error type for network errors. // */ // public static final int ERROR_NETWORK = 2; // // private int type; // private int code; // private String message; // // protected UploadError(int type, int code, String message) { // this.type = type; // this.code = code; // this.message = message; // } // // /** // * Gets the error type. // * @return Integer with value {@link #ERROR_RESPONSE} or {@link #ERROR_NETWORK}. // */ // public int getType() { // return type; // } // // /** // * Gets the error code. // * @return HTTP status returned by the server or 0 in case of network error. // */ // public int getCode() { // return code; // } // // /** // * Gets description of the error. // * @return Any message returned by the server or exception message in case of network error. // */ // public String getMessage() { // return message; // } // }
import android.content.Context; import android.util.Log; import com.nuvoex.fileuploader.UploadBroadcastReceiver; import com.nuvoex.fileuploader.UploadError; import java.util.Map;
package com.nuvoex.fileuploadersample; /** * Created by dilip on 10/01/17. */ public class UploadReceiver extends UploadBroadcastReceiver { @Override public void onStart(Context context, String uploadId, Map<String, String> extras) { } @Override
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadBroadcastReceiver.java // public abstract class UploadBroadcastReceiver extends BroadcastReceiver { // // /** // * Delegates the generic {@code onReceive} event to a file upload event. Subclasses should override // * the event methods and not this method. // * @param context The context in which the receiver is running. // * @param intent An {@code Intent} containing data about the file upload. // */ // @Override // public void onReceive(Context context, Intent intent) { // if (intent == null || !intent.hasExtra(Constants.Keys.EXTRA_UPLOAD_STATUS) || !intent.hasExtra(Intent.EXTRA_UID)) { // return; // } // // String uploadId = intent.getStringExtra(Intent.EXTRA_UID); // Map<String, String> extras = (Map<String, String>) intent.getSerializableExtra(Constants.Keys.EXTRA_EXTRAS); // // switch (intent.getIntExtra(Constants.Keys.EXTRA_UPLOAD_STATUS, 0)) { // case Constants.Status.STARTED: // onStart(context, uploadId, extras); // break; // case Constants.Status.FAILED: // onFail(context, uploadId, extras, (UploadError) intent.getSerializableExtra(Constants.Keys.EXTRA_UPLOAD_ERROR)); // break; // case Constants.Status.COMPLETED: // onComplete(context, uploadId, extras); // break; // case Constants.Status.CANCELLED: // onCancel(context, uploadId, extras); // break; // } // } // // /** // * Called when a file upload begins. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // */ // public abstract void onStart(Context context, String uploadId, Map<String, String> extras); // // /** // * Called when a file upload fails. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // * @param error {@link UploadError} with details of the failure. // */ // public abstract void onFail(Context context, String uploadId, Map<String, String> extras, UploadError error); // // /** // * Called when a file upload is completed. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // */ // public abstract void onComplete(Context context, String uploadId, Map<String, String> extras); // // /** // * Called when a file upload is cancelled. // * @param context The context in which the receiver is running. // * @param uploadId Unique ID of the file upload request. // * @param extras Any extra information associated with this file upload. // * @see UploadInfo#setExtras(Map) Adding extra information to file upload // */ // public abstract void onCancel(Context context, String uploadId, Map<String, String> extras); // } // // Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadError.java // public class UploadError implements Serializable { // // /** // * Error type for client or server errors. // */ // public static final int ERROR_RESPONSE = 1; // // /** // * Error type for network errors. // */ // public static final int ERROR_NETWORK = 2; // // private int type; // private int code; // private String message; // // protected UploadError(int type, int code, String message) { // this.type = type; // this.code = code; // this.message = message; // } // // /** // * Gets the error type. // * @return Integer with value {@link #ERROR_RESPONSE} or {@link #ERROR_NETWORK}. // */ // public int getType() { // return type; // } // // /** // * Gets the error code. // * @return HTTP status returned by the server or 0 in case of network error. // */ // public int getCode() { // return code; // } // // /** // * Gets description of the error. // * @return Any message returned by the server or exception message in case of network error. // */ // public String getMessage() { // return message; // } // } // Path: sample/src/main/java/com/nuvoex/fileuploadersample/UploadReceiver.java import android.content.Context; import android.util.Log; import com.nuvoex.fileuploader.UploadBroadcastReceiver; import com.nuvoex.fileuploader.UploadError; import java.util.Map; package com.nuvoex.fileuploadersample; /** * Created by dilip on 10/01/17. */ public class UploadReceiver extends UploadBroadcastReceiver { @Override public void onStart(Context context, String uploadId, Map<String, String> extras) { } @Override
public void onFail(Context context, String uploadId, Map<String, String> extras, UploadError error) {
Nuvoex/async-file-uploader
sample/src/main/java/com/nuvoex/fileuploadersample/SampleApplication.java
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadQueue.java // public class UploadQueue { // // private static FirebaseJobDispatcher dispatcher; // private static int logLevel = Integer.MAX_VALUE; // // private static FirebaseJobDispatcher getDispatcher(Context context) { // if (dispatcher == null) { // Driver driver = new GooglePlayDriver(context.getApplicationContext()); // dispatcher = new FirebaseJobDispatcher(driver); // } // return dispatcher; // } // // /** // * Sets the log level. Logging is disabled by default. // * @param level The log level. Must be one of {@link Log#VERBOSE}, {@link Log#DEBUG}, // * {@link Log#INFO}, {@link Log#WARN} or {@link Log#ERROR}. // */ // public static void setLogLevel(int level) { // logLevel = level; // } // // /** // * Gets the log level. // * @see #setLogLevel(int) // * @return The log level. Default value is {@link Integer#MAX_VALUE}. // */ // public static int getLogLevel() { // return logLevel; // } // // /** // * Schedules a file upload to be performed in the background. Uploads are queued for // * immediate execution as long as a network connection is available. Otherwise it will wait // * until a connection is established. Uploads are automatically retried if they fail and // * across system reboots. The exact time at which the upload is attempted is decided by the // * system for optimizing device resources. // * @param context The application context. // * @param uploadInfo {@link UploadInfo} for this file upload. // * @return {@code true} if the upload was scheduled successfully, {@code false} otherwise. // */ // public static boolean schedule(Context context, UploadInfo uploadInfo) { // if (uploadInfo == null) { // return false; // } // if (uploadInfo.getExtras() == null) { // uploadInfo.setExtras(new HashMap<String, String>()); // } // JobList jobList = JobList.getJobList(context); // jobList.add(uploadInfo); // jobList.commit(); // return scheduleJob(context); // } // // /** // * Attempts to execute all scheduled file uploads. Uploads are not immediately performed, but // * performed at an optimum time decided by the system for efficient use of device resources. // * @param context The application context. // * @return {@code true} if successful, {@code false} otherwise. // */ // public static boolean flush(Context context) { // return scheduleJob(context); // } // // /** // * Removes all scheduled file uploads. // * @param context The application context. // */ // public static void clear(Context context) { // JobList jobList = JobList.getJobList(context); // jobList.clear(); // jobList.commit(); // } // // private static boolean scheduleJob(Context context) { // FirebaseJobDispatcher dispatcher = getDispatcher(context); // Job job = dispatcher.newJobBuilder() // .setService(UploadService.class) // .setTag(context.getPackageName() + ".uploadqueue") // .setConstraints(Constraint.ON_ANY_NETWORK) // .setTrigger(Trigger.NOW) // .setLifetime(Lifetime.FOREVER) // .setRecurring(false) // .setReplaceCurrent(true) // .build(); // int result = dispatcher.schedule(job); // if (result == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS) { // Logger.v("Job scheduled"); // return true; // } else { // Logger.v("Job not scheduled"); // return false; // } // } // }
import android.app.Application; import android.util.Log; import com.nuvoex.fileuploader.UploadQueue;
package com.nuvoex.fileuploadersample; /** * Created by dilip on 19/01/17. */ public class SampleApplication extends Application { @Override public void onCreate() { super.onCreate();
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadQueue.java // public class UploadQueue { // // private static FirebaseJobDispatcher dispatcher; // private static int logLevel = Integer.MAX_VALUE; // // private static FirebaseJobDispatcher getDispatcher(Context context) { // if (dispatcher == null) { // Driver driver = new GooglePlayDriver(context.getApplicationContext()); // dispatcher = new FirebaseJobDispatcher(driver); // } // return dispatcher; // } // // /** // * Sets the log level. Logging is disabled by default. // * @param level The log level. Must be one of {@link Log#VERBOSE}, {@link Log#DEBUG}, // * {@link Log#INFO}, {@link Log#WARN} or {@link Log#ERROR}. // */ // public static void setLogLevel(int level) { // logLevel = level; // } // // /** // * Gets the log level. // * @see #setLogLevel(int) // * @return The log level. Default value is {@link Integer#MAX_VALUE}. // */ // public static int getLogLevel() { // return logLevel; // } // // /** // * Schedules a file upload to be performed in the background. Uploads are queued for // * immediate execution as long as a network connection is available. Otherwise it will wait // * until a connection is established. Uploads are automatically retried if they fail and // * across system reboots. The exact time at which the upload is attempted is decided by the // * system for optimizing device resources. // * @param context The application context. // * @param uploadInfo {@link UploadInfo} for this file upload. // * @return {@code true} if the upload was scheduled successfully, {@code false} otherwise. // */ // public static boolean schedule(Context context, UploadInfo uploadInfo) { // if (uploadInfo == null) { // return false; // } // if (uploadInfo.getExtras() == null) { // uploadInfo.setExtras(new HashMap<String, String>()); // } // JobList jobList = JobList.getJobList(context); // jobList.add(uploadInfo); // jobList.commit(); // return scheduleJob(context); // } // // /** // * Attempts to execute all scheduled file uploads. Uploads are not immediately performed, but // * performed at an optimum time decided by the system for efficient use of device resources. // * @param context The application context. // * @return {@code true} if successful, {@code false} otherwise. // */ // public static boolean flush(Context context) { // return scheduleJob(context); // } // // /** // * Removes all scheduled file uploads. // * @param context The application context. // */ // public static void clear(Context context) { // JobList jobList = JobList.getJobList(context); // jobList.clear(); // jobList.commit(); // } // // private static boolean scheduleJob(Context context) { // FirebaseJobDispatcher dispatcher = getDispatcher(context); // Job job = dispatcher.newJobBuilder() // .setService(UploadService.class) // .setTag(context.getPackageName() + ".uploadqueue") // .setConstraints(Constraint.ON_ANY_NETWORK) // .setTrigger(Trigger.NOW) // .setLifetime(Lifetime.FOREVER) // .setRecurring(false) // .setReplaceCurrent(true) // .build(); // int result = dispatcher.schedule(job); // if (result == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS) { // Logger.v("Job scheduled"); // return true; // } else { // Logger.v("Job not scheduled"); // return false; // } // } // } // Path: sample/src/main/java/com/nuvoex/fileuploadersample/SampleApplication.java import android.app.Application; import android.util.Log; import com.nuvoex.fileuploader.UploadQueue; package com.nuvoex.fileuploadersample; /** * Created by dilip on 19/01/17. */ public class SampleApplication extends Application { @Override public void onCreate() { super.onCreate();
UploadQueue.setLogLevel(Log.VERBOSE);
Nuvoex/async-file-uploader
fileuploader/src/main/java/com/nuvoex/fileuploader/network/ApiManager.java
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/utils/Constants.java // public class Constants { // // /** // * Configuration values. // */ // public final class Configs { // // /** // * Timeout for file upload requests in seconds. // */ // public static final int TIMEOUT = 60; // } // // public final class Urls { // // // dummy value, not used for uploads // public static final String BASE_URL = "https://nuvoex.com"; // } // // /** // * Keys for extra data. // */ // public final class Keys { // // public static final String EXTRA_FILE_PATH = "com.nuvoex.fileuploader.FILE_LOCAL_PATH"; // // public static final String EXTRA_UPLOAD_URL = "com.nuvoex.fileuploader.FILE_UPLOAD_URL"; // // public static final String EXTRA_DELETE_ON_UPLOAD = "com.nuvoex.fileuploader.DELETE_ON_UPLOAD"; // // public static final String EXTRA_EXTRAS = "com.nuvoex.fileuploader.EXTRAS"; // // public static final String EXTRA_UPLOAD_STATUS = "com.nuvoex.fileuploader.FILE_UPLOAD_STATUS"; // // public static final String EXTRA_UPLOAD_ERROR = "com.nuvoex.fileuploader.FILE_UPLOAD_ERROR"; // } // // /** // * Actions broadcast by upload service. // * Receivers can be declared in the manifest to respond to these broadcasts. // */ // public final class Actions { // // /** // * Broadcast action sent whenever a file upload status changes. // * @see Status List of possible status values // */ // public static final String STATUS_CHANGE = "com.nuvoex.fileuploader.ACTION_STATUS_CHANGE"; // } // // /** // * Status associated with each file upload event. // */ // public final class Status { // // /** // * File upload has started. // */ // public static final int STARTED = 1; // // /** // * File upload failed. It will be automatically retried. // */ // public static final int FAILED = 2; // // /** // * File upload completed. // */ // public static final int COMPLETED = 3; // // /** // * File upload was cancelled. It will not be retried. // */ // public static final int CANCELLED = 4; // } // // public static final String TAG = "FILE_UPLOAD"; // }
import com.nuvoex.fileuploader.utils.Constants; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import retrofit2.Retrofit;
package com.nuvoex.fileuploader.network; /** * Created by dilip on 04/01/17. */ public class ApiManager { private static Retrofit retrofit = null; private static ApiService service = null; private synchronized static Retrofit getClient() { if (retrofit == null) { OkHttpClient client = new OkHttpClient.Builder()
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/utils/Constants.java // public class Constants { // // /** // * Configuration values. // */ // public final class Configs { // // /** // * Timeout for file upload requests in seconds. // */ // public static final int TIMEOUT = 60; // } // // public final class Urls { // // // dummy value, not used for uploads // public static final String BASE_URL = "https://nuvoex.com"; // } // // /** // * Keys for extra data. // */ // public final class Keys { // // public static final String EXTRA_FILE_PATH = "com.nuvoex.fileuploader.FILE_LOCAL_PATH"; // // public static final String EXTRA_UPLOAD_URL = "com.nuvoex.fileuploader.FILE_UPLOAD_URL"; // // public static final String EXTRA_DELETE_ON_UPLOAD = "com.nuvoex.fileuploader.DELETE_ON_UPLOAD"; // // public static final String EXTRA_EXTRAS = "com.nuvoex.fileuploader.EXTRAS"; // // public static final String EXTRA_UPLOAD_STATUS = "com.nuvoex.fileuploader.FILE_UPLOAD_STATUS"; // // public static final String EXTRA_UPLOAD_ERROR = "com.nuvoex.fileuploader.FILE_UPLOAD_ERROR"; // } // // /** // * Actions broadcast by upload service. // * Receivers can be declared in the manifest to respond to these broadcasts. // */ // public final class Actions { // // /** // * Broadcast action sent whenever a file upload status changes. // * @see Status List of possible status values // */ // public static final String STATUS_CHANGE = "com.nuvoex.fileuploader.ACTION_STATUS_CHANGE"; // } // // /** // * Status associated with each file upload event. // */ // public final class Status { // // /** // * File upload has started. // */ // public static final int STARTED = 1; // // /** // * File upload failed. It will be automatically retried. // */ // public static final int FAILED = 2; // // /** // * File upload completed. // */ // public static final int COMPLETED = 3; // // /** // * File upload was cancelled. It will not be retried. // */ // public static final int CANCELLED = 4; // } // // public static final String TAG = "FILE_UPLOAD"; // } // Path: fileuploader/src/main/java/com/nuvoex/fileuploader/network/ApiManager.java import com.nuvoex.fileuploader.utils.Constants; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import retrofit2.Retrofit; package com.nuvoex.fileuploader.network; /** * Created by dilip on 04/01/17. */ public class ApiManager { private static Retrofit retrofit = null; private static ApiService service = null; private synchronized static Retrofit getClient() { if (retrofit == null) { OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(Constants.Configs.TIMEOUT, TimeUnit.SECONDS)
Nuvoex/async-file-uploader
fileuploader/src/main/java/com/nuvoex/fileuploader/utils/Logger.java
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadQueue.java // public class UploadQueue { // // private static FirebaseJobDispatcher dispatcher; // private static int logLevel = Integer.MAX_VALUE; // // private static FirebaseJobDispatcher getDispatcher(Context context) { // if (dispatcher == null) { // Driver driver = new GooglePlayDriver(context.getApplicationContext()); // dispatcher = new FirebaseJobDispatcher(driver); // } // return dispatcher; // } // // /** // * Sets the log level. Logging is disabled by default. // * @param level The log level. Must be one of {@link Log#VERBOSE}, {@link Log#DEBUG}, // * {@link Log#INFO}, {@link Log#WARN} or {@link Log#ERROR}. // */ // public static void setLogLevel(int level) { // logLevel = level; // } // // /** // * Gets the log level. // * @see #setLogLevel(int) // * @return The log level. Default value is {@link Integer#MAX_VALUE}. // */ // public static int getLogLevel() { // return logLevel; // } // // /** // * Schedules a file upload to be performed in the background. Uploads are queued for // * immediate execution as long as a network connection is available. Otherwise it will wait // * until a connection is established. Uploads are automatically retried if they fail and // * across system reboots. The exact time at which the upload is attempted is decided by the // * system for optimizing device resources. // * @param context The application context. // * @param uploadInfo {@link UploadInfo} for this file upload. // * @return {@code true} if the upload was scheduled successfully, {@code false} otherwise. // */ // public static boolean schedule(Context context, UploadInfo uploadInfo) { // if (uploadInfo == null) { // return false; // } // if (uploadInfo.getExtras() == null) { // uploadInfo.setExtras(new HashMap<String, String>()); // } // JobList jobList = JobList.getJobList(context); // jobList.add(uploadInfo); // jobList.commit(); // return scheduleJob(context); // } // // /** // * Attempts to execute all scheduled file uploads. Uploads are not immediately performed, but // * performed at an optimum time decided by the system for efficient use of device resources. // * @param context The application context. // * @return {@code true} if successful, {@code false} otherwise. // */ // public static boolean flush(Context context) { // return scheduleJob(context); // } // // /** // * Removes all scheduled file uploads. // * @param context The application context. // */ // public static void clear(Context context) { // JobList jobList = JobList.getJobList(context); // jobList.clear(); // jobList.commit(); // } // // private static boolean scheduleJob(Context context) { // FirebaseJobDispatcher dispatcher = getDispatcher(context); // Job job = dispatcher.newJobBuilder() // .setService(UploadService.class) // .setTag(context.getPackageName() + ".uploadqueue") // .setConstraints(Constraint.ON_ANY_NETWORK) // .setTrigger(Trigger.NOW) // .setLifetime(Lifetime.FOREVER) // .setRecurring(false) // .setReplaceCurrent(true) // .build(); // int result = dispatcher.schedule(job); // if (result == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS) { // Logger.v("Job scheduled"); // return true; // } else { // Logger.v("Job not scheduled"); // return false; // } // } // }
import android.util.Log; import com.nuvoex.fileuploader.UploadQueue;
package com.nuvoex.fileuploader.utils; /** * Created by dilip on 10/02/17. */ /** * Utility class for logging messages to the system log. By default no message is logged. * {@link UploadQueue#setLogLevel(int)} sets the log level. */ public class Logger { /** * Send a {@link Log#VERBOSE} message. * @param msg The message to be logged. */ public static void v(String msg) {
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadQueue.java // public class UploadQueue { // // private static FirebaseJobDispatcher dispatcher; // private static int logLevel = Integer.MAX_VALUE; // // private static FirebaseJobDispatcher getDispatcher(Context context) { // if (dispatcher == null) { // Driver driver = new GooglePlayDriver(context.getApplicationContext()); // dispatcher = new FirebaseJobDispatcher(driver); // } // return dispatcher; // } // // /** // * Sets the log level. Logging is disabled by default. // * @param level The log level. Must be one of {@link Log#VERBOSE}, {@link Log#DEBUG}, // * {@link Log#INFO}, {@link Log#WARN} or {@link Log#ERROR}. // */ // public static void setLogLevel(int level) { // logLevel = level; // } // // /** // * Gets the log level. // * @see #setLogLevel(int) // * @return The log level. Default value is {@link Integer#MAX_VALUE}. // */ // public static int getLogLevel() { // return logLevel; // } // // /** // * Schedules a file upload to be performed in the background. Uploads are queued for // * immediate execution as long as a network connection is available. Otherwise it will wait // * until a connection is established. Uploads are automatically retried if they fail and // * across system reboots. The exact time at which the upload is attempted is decided by the // * system for optimizing device resources. // * @param context The application context. // * @param uploadInfo {@link UploadInfo} for this file upload. // * @return {@code true} if the upload was scheduled successfully, {@code false} otherwise. // */ // public static boolean schedule(Context context, UploadInfo uploadInfo) { // if (uploadInfo == null) { // return false; // } // if (uploadInfo.getExtras() == null) { // uploadInfo.setExtras(new HashMap<String, String>()); // } // JobList jobList = JobList.getJobList(context); // jobList.add(uploadInfo); // jobList.commit(); // return scheduleJob(context); // } // // /** // * Attempts to execute all scheduled file uploads. Uploads are not immediately performed, but // * performed at an optimum time decided by the system for efficient use of device resources. // * @param context The application context. // * @return {@code true} if successful, {@code false} otherwise. // */ // public static boolean flush(Context context) { // return scheduleJob(context); // } // // /** // * Removes all scheduled file uploads. // * @param context The application context. // */ // public static void clear(Context context) { // JobList jobList = JobList.getJobList(context); // jobList.clear(); // jobList.commit(); // } // // private static boolean scheduleJob(Context context) { // FirebaseJobDispatcher dispatcher = getDispatcher(context); // Job job = dispatcher.newJobBuilder() // .setService(UploadService.class) // .setTag(context.getPackageName() + ".uploadqueue") // .setConstraints(Constraint.ON_ANY_NETWORK) // .setTrigger(Trigger.NOW) // .setLifetime(Lifetime.FOREVER) // .setRecurring(false) // .setReplaceCurrent(true) // .build(); // int result = dispatcher.schedule(job); // if (result == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS) { // Logger.v("Job scheduled"); // return true; // } else { // Logger.v("Job not scheduled"); // return false; // } // } // } // Path: fileuploader/src/main/java/com/nuvoex/fileuploader/utils/Logger.java import android.util.Log; import com.nuvoex.fileuploader.UploadQueue; package com.nuvoex.fileuploader.utils; /** * Created by dilip on 10/02/17. */ /** * Utility class for logging messages to the system log. By default no message is logged. * {@link UploadQueue#setLogLevel(int)} sets the log level. */ public class Logger { /** * Send a {@link Log#VERBOSE} message. * @param msg The message to be logged. */ public static void v(String msg) {
if (UploadQueue.getLogLevel() <= Log.VERBOSE) {
Nuvoex/async-file-uploader
fileuploader/src/main/java/com/nuvoex/fileuploader/utils/JobList.java
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadInfo.java // public class UploadInfo { // // private String mUploadId; // private String mFilePath; // private String mUploadUrl; // private boolean mDeleteOnUpload; // private Map<String, String> mExtras; // // /** // * Sets the application level unique ID for this file upload. // * @param uploadId String value. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setUploadId(String uploadId) { // this.mUploadId = uploadId; // return this; // } // // /** // * Sets the local path of the file to upload. // * @param filePath Absolute file path. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setFilePath(String filePath) { // this.mFilePath = filePath; // return this; // } // // /** // * Sets the url to which the file is to be uploaded. Url must support PUT operation without authentication. // * @param uploadUrl An HTTP url. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setUploadUrl(String uploadUrl) { // this.mUploadUrl = uploadUrl; // return this; // } // // /** // * Sets whether the file should be deleted after it has been uploaded. // * @param shouldDelete {@code true} to delete, {@code false} otherwise. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setDeleteOnUpload(boolean shouldDelete) { // this.mDeleteOnUpload = shouldDelete; // return this; // } // // /** // * Sets any extra information to be associated with this file upload. // * @param extras A hash map with key value pairs. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setExtras(Map<String, String> extras) { // this.mExtras = extras; // return this; // } // // /** // * Gets the unique ID for the file upload. // * @return String value. // */ // public String getUploadId() { // return this.mUploadId; // } // // /** // * Gets the absolute path of file to upload. // * @return File path. // */ // public String getFilePath() { // return this.mFilePath; // } // // /** // * Gets the url to upload the file to. // * @return Url. // */ // public String getUploadUrl() { // return this.mUploadUrl; // } // // /** // * Gets whether the file will be deleted after upload. // * @return Boolean value. // */ // public boolean getDeleteOnUpload() { // return this.mDeleteOnUpload; // } // // /** // * Gets any extra information associated with this file upload. // * @return A hash map of key value pairs. // */ // public Map<String, String> getExtras() { // return this.mExtras; // } // }
import android.content.Context; import android.os.Environment; import com.nuvoex.fileuploader.UploadInfo; import org.json.JSONException; import org.json.JSONObject; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set;
package com.nuvoex.fileuploader.utils; /** * Created by dilip on 19/01/17. */ /** * Helper class that encapsulates storage and retrieval of upload jobs to persistent storage. * Data is stored in an external directory outside the application's private space so that it is * retained across installs. */ public class JobList extends Properties { /** * Name of directory created in external storage for storing data. */ private static final String STORAGE_DIR = ".fileuploader"; private static final String DEFAULT_LIST = "default"; private String mPackageName; public static JobList getJobList(Context context) { return new JobList(context); } private JobList(Context context) { this.mPackageName = context.getPackageName(); try { File storageFile = getStorageFile(); if (storageFile.exists()) { InputStream inputStream = new FileInputStream(getStorageFile()); loadFromXML(inputStream); } } catch (IOException e) { Logger.e("Error reading job list", e); } catch (NullPointerException e) { Logger.e("Error reading job list", e); } } /** * Adds a new file upload. * @param uploadInfo {@link UploadInfo} for this file upload. */
// Path: fileuploader/src/main/java/com/nuvoex/fileuploader/UploadInfo.java // public class UploadInfo { // // private String mUploadId; // private String mFilePath; // private String mUploadUrl; // private boolean mDeleteOnUpload; // private Map<String, String> mExtras; // // /** // * Sets the application level unique ID for this file upload. // * @param uploadId String value. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setUploadId(String uploadId) { // this.mUploadId = uploadId; // return this; // } // // /** // * Sets the local path of the file to upload. // * @param filePath Absolute file path. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setFilePath(String filePath) { // this.mFilePath = filePath; // return this; // } // // /** // * Sets the url to which the file is to be uploaded. Url must support PUT operation without authentication. // * @param uploadUrl An HTTP url. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setUploadUrl(String uploadUrl) { // this.mUploadUrl = uploadUrl; // return this; // } // // /** // * Sets whether the file should be deleted after it has been uploaded. // * @param shouldDelete {@code true} to delete, {@code false} otherwise. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setDeleteOnUpload(boolean shouldDelete) { // this.mDeleteOnUpload = shouldDelete; // return this; // } // // /** // * Sets any extra information to be associated with this file upload. // * @param extras A hash map with key value pairs. // * @return A reference to the same {@code UploadInfo} object, so calls to set properties can be chained. // */ // public UploadInfo setExtras(Map<String, String> extras) { // this.mExtras = extras; // return this; // } // // /** // * Gets the unique ID for the file upload. // * @return String value. // */ // public String getUploadId() { // return this.mUploadId; // } // // /** // * Gets the absolute path of file to upload. // * @return File path. // */ // public String getFilePath() { // return this.mFilePath; // } // // /** // * Gets the url to upload the file to. // * @return Url. // */ // public String getUploadUrl() { // return this.mUploadUrl; // } // // /** // * Gets whether the file will be deleted after upload. // * @return Boolean value. // */ // public boolean getDeleteOnUpload() { // return this.mDeleteOnUpload; // } // // /** // * Gets any extra information associated with this file upload. // * @return A hash map of key value pairs. // */ // public Map<String, String> getExtras() { // return this.mExtras; // } // } // Path: fileuploader/src/main/java/com/nuvoex/fileuploader/utils/JobList.java import android.content.Context; import android.os.Environment; import com.nuvoex.fileuploader.UploadInfo; import org.json.JSONException; import org.json.JSONObject; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.Set; package com.nuvoex.fileuploader.utils; /** * Created by dilip on 19/01/17. */ /** * Helper class that encapsulates storage and retrieval of upload jobs to persistent storage. * Data is stored in an external directory outside the application's private space so that it is * retained across installs. */ public class JobList extends Properties { /** * Name of directory created in external storage for storing data. */ private static final String STORAGE_DIR = ".fileuploader"; private static final String DEFAULT_LIST = "default"; private String mPackageName; public static JobList getJobList(Context context) { return new JobList(context); } private JobList(Context context) { this.mPackageName = context.getPackageName(); try { File storageFile = getStorageFile(); if (storageFile.exists()) { InputStream inputStream = new FileInputStream(getStorageFile()); loadFromXML(inputStream); } } catch (IOException e) { Logger.e("Error reading job list", e); } catch (NullPointerException e) { Logger.e("Error reading job list", e); } } /** * Adds a new file upload. * @param uploadInfo {@link UploadInfo} for this file upload. */
public void add(UploadInfo uploadInfo) {
jenkinsci/git-plugin
src/test/java/hudson/plugins/git/extensions/impl/CloneOptionNoTagsTest.java
// Path: src/test/java/hudson/plugins/git/TestGitRepo.java // public class TestGitRepo { // protected String name; // The name of this repository. // protected TaskListener listener; // // /** // * This is where the commit commands create a Git repository. // */ // public File gitDir; // was "workDir" // public FilePath gitDirPath; // was "workspace" // public GitClient git; // // public final PersonIdent johnDoe = new PersonIdent("John Doe", "john@doe.com"); // public final PersonIdent janeDoe = new PersonIdent("Jane Doe", "jane@doe.com"); // // public TestGitRepo(String name, File tmpDir, TaskListener listener) throws IOException, InterruptedException { // this.name = name; // this.listener = listener; // // EnvVars envVars = new EnvVars(); // // gitDir = tmpDir; // User john = User.getOrCreateByIdOrFullName(johnDoe.getName()); // UserProperty johnsMailerProperty = new Mailer.UserProperty(johnDoe.getEmailAddress()); // john.addProperty(johnsMailerProperty); // // User jane = User.getOrCreateByIdOrFullName(janeDoe.getName()); // UserProperty janesMailerProperty = new Mailer.UserProperty(janeDoe.getEmailAddress()); // jane.addProperty(janesMailerProperty); // // // initialize the git interface. // gitDirPath = new FilePath(gitDir); // git = Git.with(listener, envVars).in(gitDir).getClient(); // // // finally: initialize the repo // git.init(); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with default content // * @param committer author and committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final PersonIdent committer, final String message) // throws GitException, InterruptedException { // return commit(fileName, fileName, committer, committer, message); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with default content // * @param author author of the commit // * @param committer committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final PersonIdent author, final PersonIdent committer, final String message) // throws GitException, InterruptedException { // return commit(fileName, fileName, author, committer, message); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with the given content // * @param fileContent content of the commit // * @param committer author and committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final String fileContent, final PersonIdent committer, final String message) // throws GitException, InterruptedException { // return commit(fileName, fileContent, committer, committer, message); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with the given content // * @param fileContent content of the commit // * @param author author of the commit // * @param committer committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final String fileContent, final PersonIdent author, final PersonIdent committer, // final String message) throws GitException, InterruptedException { // FilePath file = gitDirPath.child(fileName); // try { // file.write(fileContent, null); // } catch (Exception e) { // throw new GitException("unable to write file", e); // } // git.add(fileName); // git.setAuthor(author); // git.setCommitter(committer); // git.commit(message); // return git.revParse("HEAD").getName(); // } // // public void tag(String tagName, String comment) throws GitException, InterruptedException { // git.tag(tagName, comment); // } // // public List<UserRemoteConfig> remoteConfigs() throws IOException { // return remoteConfigs(null); // } // // List<UserRemoteConfig> remoteConfigs(StandardCredentials credentials) { // String credentialsId = credentials == null ? null : credentials.getId(); // List<UserRemoteConfig> list = new ArrayList<>(); // list.add(new UserRemoteConfig(gitDir.getAbsolutePath(), "origin", "", credentialsId)); // return list; // } // }
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Set; import hudson.model.Result; import hudson.model.FreeStyleProject; import hudson.plugins.git.TestGitRepo; import hudson.plugins.git.extensions.GitSCMExtensionTest; import hudson.plugins.git.extensions.GitSCMExtension; import org.jenkinsci.plugins.gitclient.Git; import org.jenkinsci.plugins.gitclient.GitClient; import org.junit.Test;
package hudson.plugins.git.extensions.impl; /** * @author Ronny Händel */ public class CloneOptionNoTagsTest extends GitSCMExtensionTest { FreeStyleProject project;
// Path: src/test/java/hudson/plugins/git/TestGitRepo.java // public class TestGitRepo { // protected String name; // The name of this repository. // protected TaskListener listener; // // /** // * This is where the commit commands create a Git repository. // */ // public File gitDir; // was "workDir" // public FilePath gitDirPath; // was "workspace" // public GitClient git; // // public final PersonIdent johnDoe = new PersonIdent("John Doe", "john@doe.com"); // public final PersonIdent janeDoe = new PersonIdent("Jane Doe", "jane@doe.com"); // // public TestGitRepo(String name, File tmpDir, TaskListener listener) throws IOException, InterruptedException { // this.name = name; // this.listener = listener; // // EnvVars envVars = new EnvVars(); // // gitDir = tmpDir; // User john = User.getOrCreateByIdOrFullName(johnDoe.getName()); // UserProperty johnsMailerProperty = new Mailer.UserProperty(johnDoe.getEmailAddress()); // john.addProperty(johnsMailerProperty); // // User jane = User.getOrCreateByIdOrFullName(janeDoe.getName()); // UserProperty janesMailerProperty = new Mailer.UserProperty(janeDoe.getEmailAddress()); // jane.addProperty(janesMailerProperty); // // // initialize the git interface. // gitDirPath = new FilePath(gitDir); // git = Git.with(listener, envVars).in(gitDir).getClient(); // // // finally: initialize the repo // git.init(); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with default content // * @param committer author and committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final PersonIdent committer, final String message) // throws GitException, InterruptedException { // return commit(fileName, fileName, committer, committer, message); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with default content // * @param author author of the commit // * @param committer committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final PersonIdent author, final PersonIdent committer, final String message) // throws GitException, InterruptedException { // return commit(fileName, fileName, author, committer, message); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with the given content // * @param fileContent content of the commit // * @param committer author and committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final String fileContent, final PersonIdent committer, final String message) // throws GitException, InterruptedException { // return commit(fileName, fileContent, committer, committer, message); // } // // /** // * Creates a commit in current repo. // * @param fileName relative path to the file to be committed with the given content // * @param fileContent content of the commit // * @param author author of the commit // * @param committer committer of this commit // * @param message commit message // * @return SHA1 of latest commit // * @throws GitException on git error // * @throws InterruptedException when interrupted // */ // public String commit(final String fileName, final String fileContent, final PersonIdent author, final PersonIdent committer, // final String message) throws GitException, InterruptedException { // FilePath file = gitDirPath.child(fileName); // try { // file.write(fileContent, null); // } catch (Exception e) { // throw new GitException("unable to write file", e); // } // git.add(fileName); // git.setAuthor(author); // git.setCommitter(committer); // git.commit(message); // return git.revParse("HEAD").getName(); // } // // public void tag(String tagName, String comment) throws GitException, InterruptedException { // git.tag(tagName, comment); // } // // public List<UserRemoteConfig> remoteConfigs() throws IOException { // return remoteConfigs(null); // } // // List<UserRemoteConfig> remoteConfigs(StandardCredentials credentials) { // String credentialsId = credentials == null ? null : credentials.getId(); // List<UserRemoteConfig> list = new ArrayList<>(); // list.add(new UserRemoteConfig(gitDir.getAbsolutePath(), "origin", "", credentialsId)); // return list; // } // } // Path: src/test/java/hudson/plugins/git/extensions/impl/CloneOptionNoTagsTest.java import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.Set; import hudson.model.Result; import hudson.model.FreeStyleProject; import hudson.plugins.git.TestGitRepo; import hudson.plugins.git.extensions.GitSCMExtensionTest; import hudson.plugins.git.extensions.GitSCMExtension; import org.jenkinsci.plugins.gitclient.Git; import org.jenkinsci.plugins.gitclient.GitClient; import org.junit.Test; package hudson.plugins.git.extensions.impl; /** * @author Ronny Händel */ public class CloneOptionNoTagsTest extends GitSCMExtensionTest { FreeStyleProject project;
TestGitRepo repo;
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/Observers.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/ThrowableVisitor.java // public interface ThrowableVisitor extends Visitor<Throwable, Void>{ // // /** // * visit the throwable. // */ // Void visit(Throwable t); // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor.java // public interface Visitor<T, R> { // // /** // * visit the target object // * @param t the object t. // * @return the result // */ // R visit(T t); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor1.java // public interface Visitor1<T, Param, Result> { // // /** // * visit for result // * @param t the element // * @param param the parameter // * @return the result // */ // Result visit(T t, Param param); // // }
import com.heaven7.java.visitor.ThrowableVisitor; import com.heaven7.java.visitor.Visitor; import com.heaven7.java.visitor.Visitor1; import com.heaven7.java.visitor.anno.Nullable;
package com.heaven7.java.visitor.util; /** * help for observer * * @author heaven7 * @since 1.1.7 */ public final class Observers { private static final WrappedObserver<Object, Object> OBSERVER_DEFAULT = new WrappedObserver<Object, Object>(null); private Observers() { } /** * get the wrapped observer * @param <T> the element type * @param <R> the return type. * @param base the base observer. * @return the wrapped observer. * @since 2.0.0 */ public static <T, R> Observer<T,R> wrappedObserver(Observer<T,R> base){ return new WrappedObserver<T,R>(base); } /** * get the default observer * @param <T> the element type * @param <R> the return type. * @return the default observer. * @since 2.0.0 */ @SuppressWarnings("unchecked") public static <T, R> Observer<T,R> defaultObserver(){ return (Observer<T, R>) OBSERVER_DEFAULT; } /** * construct a {@linkplain Observer} from target success runnable. * * @param <T> * the element type * @param success * the success runnable. * @return a {@linkplain Observer} * @see Observer * @since 1.1.7 */ public static <T> Observer<T, Void> from(Runnable success) { return from(success, null, null); } /** * construct a {@linkplain Observer} from target runnables(success and * failed). * * @param <T> * the element type * @param success * the success runnable. * @param failed * the failed runnable * @return a {@linkplain Observer} * @see Observer * @since 1.1.7 */ public static <T> Observer<T, Void> from(Runnable success, @Nullable Runnable failed) { return from(success, failed, null); } /** * construct a {@linkplain Observer} from target callbacks(success,failed * and throwable). * * @param <T> * the element type * @param success * the success runnable. * @param failed * the failed runnable * @param exception * the throwable visitor. * @return a {@linkplain Observer} * @see Observer * @since 1.1.7 */ public static <T> Observer<T, Void> from(final Runnable success, @Nullable final Runnable failed,
// Path: Visitor/src/main/java/com/heaven7/java/visitor/ThrowableVisitor.java // public interface ThrowableVisitor extends Visitor<Throwable, Void>{ // // /** // * visit the throwable. // */ // Void visit(Throwable t); // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor.java // public interface Visitor<T, R> { // // /** // * visit the target object // * @param t the object t. // * @return the result // */ // R visit(T t); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor1.java // public interface Visitor1<T, Param, Result> { // // /** // * visit for result // * @param t the element // * @param param the parameter // * @return the result // */ // Result visit(T t, Param param); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observers.java import com.heaven7.java.visitor.ThrowableVisitor; import com.heaven7.java.visitor.Visitor; import com.heaven7.java.visitor.Visitor1; import com.heaven7.java.visitor.anno.Nullable; package com.heaven7.java.visitor.util; /** * help for observer * * @author heaven7 * @since 1.1.7 */ public final class Observers { private static final WrappedObserver<Object, Object> OBSERVER_DEFAULT = new WrappedObserver<Object, Object>(null); private Observers() { } /** * get the wrapped observer * @param <T> the element type * @param <R> the return type. * @param base the base observer. * @return the wrapped observer. * @since 2.0.0 */ public static <T, R> Observer<T,R> wrappedObserver(Observer<T,R> base){ return new WrappedObserver<T,R>(base); } /** * get the default observer * @param <T> the element type * @param <R> the return type. * @return the default observer. * @since 2.0.0 */ @SuppressWarnings("unchecked") public static <T, R> Observer<T,R> defaultObserver(){ return (Observer<T, R>) OBSERVER_DEFAULT; } /** * construct a {@linkplain Observer} from target success runnable. * * @param <T> * the element type * @param success * the success runnable. * @return a {@linkplain Observer} * @see Observer * @since 1.1.7 */ public static <T> Observer<T, Void> from(Runnable success) { return from(success, null, null); } /** * construct a {@linkplain Observer} from target runnables(success and * failed). * * @param <T> * the element type * @param success * the success runnable. * @param failed * the failed runnable * @return a {@linkplain Observer} * @see Observer * @since 1.1.7 */ public static <T> Observer<T, Void> from(Runnable success, @Nullable Runnable failed) { return from(success, failed, null); } /** * construct a {@linkplain Observer} from target callbacks(success,failed * and throwable). * * @param <T> * the element type * @param success * the success runnable. * @param failed * the failed runnable * @param exception * the throwable visitor. * @return a {@linkplain Observer} * @see Observer * @since 1.1.7 */ public static <T> Observer<T, Void> from(final Runnable success, @Nullable final Runnable failed,
final @Nullable ThrowableVisitor exception) {
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/Observers.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/ThrowableVisitor.java // public interface ThrowableVisitor extends Visitor<Throwable, Void>{ // // /** // * visit the throwable. // */ // Void visit(Throwable t); // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor.java // public interface Visitor<T, R> { // // /** // * visit the target object // * @param t the object t. // * @return the result // */ // R visit(T t); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor1.java // public interface Visitor1<T, Param, Result> { // // /** // * visit for result // * @param t the element // * @param param the parameter // * @return the result // */ // Result visit(T t, Param param); // // }
import com.heaven7.java.visitor.ThrowableVisitor; import com.heaven7.java.visitor.Visitor; import com.heaven7.java.visitor.Visitor1; import com.heaven7.java.visitor.anno.Nullable;
success.run(); } @Override public void onFailed(Object param, T t) { if (failed != null) { failed.run(); } } @Override public void onThrowable(Object param, T t, Throwable e) { if (exception != null) { exception.visit(e); } else { super.onThrowable(param, t, e); } } }; } /** * a observer that wrapped some visitor(success,failed, exception). * @author heaven7 * * @param <T> the element type of observer * @param <R> the result type of observer. * @since 2.0.0 */ public static class Observer2<T, R> extends ObserverAdapter<T, R>{
// Path: Visitor/src/main/java/com/heaven7/java/visitor/ThrowableVisitor.java // public interface ThrowableVisitor extends Visitor<Throwable, Void>{ // // /** // * visit the throwable. // */ // Void visit(Throwable t); // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor.java // public interface Visitor<T, R> { // // /** // * visit the target object // * @param t the object t. // * @return the result // */ // R visit(T t); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor1.java // public interface Visitor1<T, Param, Result> { // // /** // * visit for result // * @param t the element // * @param param the parameter // * @return the result // */ // Result visit(T t, Param param); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observers.java import com.heaven7.java.visitor.ThrowableVisitor; import com.heaven7.java.visitor.Visitor; import com.heaven7.java.visitor.Visitor1; import com.heaven7.java.visitor.anno.Nullable; success.run(); } @Override public void onFailed(Object param, T t) { if (failed != null) { failed.run(); } } @Override public void onThrowable(Object param, T t, Throwable e) { if (exception != null) { exception.visit(e); } else { super.onThrowable(param, t, e); } } }; } /** * a observer that wrapped some visitor(success,failed, exception). * @author heaven7 * * @param <T> the element type of observer * @param <R> the result type of observer. * @since 2.0.0 */ public static class Observer2<T, R> extends ObserverAdapter<T, R>{
private final Visitor<R, Void> mSuccess;
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/Observers.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/ThrowableVisitor.java // public interface ThrowableVisitor extends Visitor<Throwable, Void>{ // // /** // * visit the throwable. // */ // Void visit(Throwable t); // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor.java // public interface Visitor<T, R> { // // /** // * visit the target object // * @param t the object t. // * @return the result // */ // R visit(T t); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor1.java // public interface Visitor1<T, Param, Result> { // // /** // * visit for result // * @param t the element // * @param param the parameter // * @return the result // */ // Result visit(T t, Param param); // // }
import com.heaven7.java.visitor.ThrowableVisitor; import com.heaven7.java.visitor.Visitor; import com.heaven7.java.visitor.Visitor1; import com.heaven7.java.visitor.anno.Nullable;
@Override public void onFailed(Object param, T t) { if (failed != null) { failed.run(); } } @Override public void onThrowable(Object param, T t, Throwable e) { if (exception != null) { exception.visit(e); } else { super.onThrowable(param, t, e); } } }; } /** * a observer that wrapped some visitor(success,failed, exception). * @author heaven7 * * @param <T> the element type of observer * @param <R> the result type of observer. * @since 2.0.0 */ public static class Observer2<T, R> extends ObserverAdapter<T, R>{ private final Visitor<R, Void> mSuccess; private final Visitor<T, Void> mFailed;
// Path: Visitor/src/main/java/com/heaven7/java/visitor/ThrowableVisitor.java // public interface ThrowableVisitor extends Visitor<Throwable, Void>{ // // /** // * visit the throwable. // */ // Void visit(Throwable t); // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor.java // public interface Visitor<T, R> { // // /** // * visit the target object // * @param t the object t. // * @return the result // */ // R visit(T t); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/Visitor1.java // public interface Visitor1<T, Param, Result> { // // /** // * visit for result // * @param t the element // * @param param the parameter // * @return the result // */ // Result visit(T t, Param param); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observers.java import com.heaven7.java.visitor.ThrowableVisitor; import com.heaven7.java.visitor.Visitor; import com.heaven7.java.visitor.Visitor1; import com.heaven7.java.visitor.anno.Nullable; @Override public void onFailed(Object param, T t) { if (failed != null) { failed.run(); } } @Override public void onThrowable(Object param, T t, Throwable e) { if (exception != null) { exception.visit(e); } else { super.onThrowable(param, t, e); } } }; } /** * a observer that wrapped some visitor(success,failed, exception). * @author heaven7 * * @param <T> the element type of observer * @param <R> the result type of observer. * @since 2.0.0 */ public static class Observer2<T, R> extends ObserverAdapter<T, R>{ private final Visitor<R, Void> mSuccess; private final Visitor<T, Void> mFailed;
private final Visitor1<T, Throwable, Void> mException;
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/SparseArray2Map.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // }
import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry;
package com.heaven7.java.visitor.util; public class SparseArray2Map<E> extends AbstractMap<Integer, E> { private final SparseArray<E> mMap;
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/SparseArray2Map.java import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; package com.heaven7.java.visitor.util; public class SparseArray2Map<E> extends AbstractMap<Integer, E> { private final SparseArray<E> mMap;
private List<KeyValuePair<Integer, E>> mTempPairs;
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/collection/ListVisitService.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // }
import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.util.Observer; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List;
ListVisitService<T> filter(Object param, PredicateVisitor<T> predicate, int maxCount, List<T> dropOut); @Override ListVisitService<T> filter(Object param, Comparator<? super T> com, PredicateVisitor<T> predicate, int maxCount, List<T> dropOut); @Override ListVisitService<T> fire(FireVisitor<T> fireVisitor); @Override ListVisitService<T> fire(FireVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> fire(Object param, FireVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> fireBatch(FireBatchVisitor<T> fireVisitor); @Override ListVisitService<T> fireBatch(FireBatchVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> fireBatch(Object param, FireBatchVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> save(Collection<T> out); @Override ListVisitService<T> save(SaveVisitor<T> visitor); @Override ListVisitService<T> save(Collection<T> out, boolean clearBeforeSave); @Override ListVisitService<T> addIfNotExist(T newT); @Override
// Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/ListVisitService.java import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.util.Observer; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; ListVisitService<T> filter(Object param, PredicateVisitor<T> predicate, int maxCount, List<T> dropOut); @Override ListVisitService<T> filter(Object param, Comparator<? super T> com, PredicateVisitor<T> predicate, int maxCount, List<T> dropOut); @Override ListVisitService<T> fire(FireVisitor<T> fireVisitor); @Override ListVisitService<T> fire(FireVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> fire(Object param, FireVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> fireBatch(FireBatchVisitor<T> fireVisitor); @Override ListVisitService<T> fireBatch(FireBatchVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> fireBatch(Object param, FireBatchVisitor<T> fireVisitor, ThrowableVisitor throwVisitor); @Override ListVisitService<T> save(Collection<T> out); @Override ListVisitService<T> save(SaveVisitor<T> visitor); @Override ListVisitService<T> save(Collection<T> out, boolean clearBeforeSave); @Override ListVisitService<T> addIfNotExist(T newT); @Override
ListVisitService<T> addIfNotExist(T newT, Observer<T, Void> observer);
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/AbstractMap.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // }
import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.Collection; import java.util.List; /**
package com.heaven7.java.visitor.util; * a base impl of {@linkplain com.heaven7.java.visitor.util.Map} * @author heaven7 * * @param <K> the key type * @param <V> the value type */ public abstract class AbstractMap<K,V> implements Map<K,V> { @Override public V replace(K key, V value) { V curValue; if (((curValue = get(key)) != null) || containsKey(key)) { put(key, value); } return curValue; } @Override public boolean replace(K key, V oldValue, V newValue) { Object curValue = get(key); if (!Predicates.equals(curValue, oldValue) || (curValue == null && !containsKey(key))) { return false; } put(key, newValue); return true; } @Override public void putAll(Map<? extends K, ? extends V> map) { putAll(map.toNormalMap()); } @Override
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/AbstractMap.java import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.Collection; import java.util.List; /** package com.heaven7.java.visitor.util; * a base impl of {@linkplain com.heaven7.java.visitor.util.Map} * @author heaven7 * * @param <K> the key type * @param <V> the value type */ public abstract class AbstractMap<K,V> implements Map<K,V> { @Override public V replace(K key, V value) { V curValue; if (((curValue = get(key)) != null) || containsKey(key)) { put(key, value); } return curValue; } @Override public boolean replace(K key, V oldValue, V newValue) { Object curValue = get(key); if (!Predicates.equals(curValue, oldValue) || (curValue == null && !containsKey(key))) { return false; } put(key, newValue); return true; } @Override public void putAll(Map<? extends K, ? extends V> map) { putAll(map.toNormalMap()); } @Override
public void putPairs(Collection<KeyValuePair<K, V>> pairs) {
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/Map2Map.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // }
import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set;
package com.heaven7.java.visitor.util; /** * an instance of {@linkplain com.heaven7.java.visitor.util.Map}. convert * {@linkplain Map} to {@linkplain com.heaven7.java.visitor.util.Map} * * @author heaven7 * * @param <K> * the key type * @param <V> * the value type */ public class Map2Map<K, V> extends AbstractMap<K, V> { private final Map<K, V> mMap;
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Map2Map.java import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; package com.heaven7.java.visitor.util; /** * an instance of {@linkplain com.heaven7.java.visitor.util.Map}. convert * {@linkplain Map} to {@linkplain com.heaven7.java.visitor.util.Map} * * @author heaven7 * * @param <K> * the key type * @param <V> * the value type */ public class Map2Map<K, V> extends AbstractMap<K, V> { private final Map<K, V> mMap;
private List<KeyValuePair<K, V>> mList;
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // }
import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer;
/** * pile('leiji') the all elements to a result. * @param pileVisitor the pile visitor * @return the result * @see #pile(Object, PileVisitor) * @see #pile(Object, ResultVisitor, PileVisitor) * @since 1.2.0 */ @Independence T pile(PileVisitor<T> pileVisitor); //============================================================= 1.2.0 =================================================== /** * zip the all elements with target visitor . * <p>that is if 'case' then 'result'</p> * <ul> <h2>here is the left case with right result</h2> * <li> if predicate visitor always visit success(true) ==>cause call {@linkplain Observer#onSuccess(Object,Object)} * <li> if predicate visitor sometime visit failed(false) ==>cause call {@linkplain Observer#onFailed(Object, Object)} * <li> if occurs {@linkplain Throwable} during visit ==>cause call {@linkplain Observer#onThrowable(Object, Object, Throwable)} * </ul> * * @param param the extra parameter * @param visitor the predicate visitor * @param observer the result observer * @return this. * @since 1.1.6 */ @DependOn(classes ={OperateManager.class, IterateControl.class }) CollectionVisitService<T> zip(@Nullable Object param, PredicateVisitor<T> visitor,
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer; /** * pile('leiji') the all elements to a result. * @param pileVisitor the pile visitor * @return the result * @see #pile(Object, PileVisitor) * @see #pile(Object, ResultVisitor, PileVisitor) * @since 1.2.0 */ @Independence T pile(PileVisitor<T> pileVisitor); //============================================================= 1.2.0 =================================================== /** * zip the all elements with target visitor . * <p>that is if 'case' then 'result'</p> * <ul> <h2>here is the left case with right result</h2> * <li> if predicate visitor always visit success(true) ==>cause call {@linkplain Observer#onSuccess(Object,Object)} * <li> if predicate visitor sometime visit failed(false) ==>cause call {@linkplain Observer#onFailed(Object, Object)} * <li> if occurs {@linkplain Throwable} during visit ==>cause call {@linkplain Observer#onThrowable(Object, Object, Throwable)} * </ul> * * @param param the extra parameter * @param visitor the predicate visitor * @param observer the result observer * @return this. * @since 1.1.6 */ @DependOn(classes ={OperateManager.class, IterateControl.class }) CollectionVisitService<T> zip(@Nullable Object param, PredicateVisitor<T> visitor,
Observer<T, Void> observer);
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // }
import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer;
/** * zip service directly( without extra iterate service). * @param param the parameter * @param resultVisitor the result visitor * @param <R> the result type * @return the result visit service. * @since 1.1.7 */ @Independence <R> CollectionVisitService<R> zipService(@Nullable Object param, ResultVisitor<T, R> resultVisitor, Observer<T, List<R>> observer); /** * zip service directly( without extra iterate service). * @param resultVisitor the result visitor * @param <R> the result type * @return the result visit service. * @since 1.1.7 */ @Independence <R> CollectionVisitService<R> zipService(ResultVisitor<T, R> resultVisitor, Observer<T, List<R>> observer); //======================================================================================= /** * the operate interceptor in iteration({@linkplain Iterator} or [{@linkplain ListIterator}) for {@linkplain Collection}. * @author heaven7 * * @param <T> the type */
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer; /** * zip service directly( without extra iterate service). * @param param the parameter * @param resultVisitor the result visitor * @param <R> the result type * @return the result visit service. * @since 1.1.7 */ @Independence <R> CollectionVisitService<R> zipService(@Nullable Object param, ResultVisitor<T, R> resultVisitor, Observer<T, List<R>> observer); /** * zip service directly( without extra iterate service). * @param resultVisitor the result visitor * @param <R> the result type * @return the result visit service. * @since 1.1.7 */ @Independence <R> CollectionVisitService<R> zipService(ResultVisitor<T, R> resultVisitor, Observer<T, List<R>> observer); //======================================================================================= /** * the operate interceptor in iteration({@linkplain Iterator} or [{@linkplain ListIterator}) for {@linkplain Collection}. * @author heaven7 * * @param <T> the type */
abstract class CollectionOperateInterceptor<T> extends OperateInterceptor {
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // }
import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer;
* @param info the IterationInfo. * @return true if intercept success, this means the loop of 'for' will be 'continue'. */ public abstract boolean intercept(Iterator<T> it, T t,@Nullable Object param, IterationInfo info); } /** * The pending operate manager used to support "filter/delete/update/insert" in iteration for all Collection. * and support insert after iteration (before method return). * <ul> * <li>filter method (in iteration): <br> {@linkplain OperateManager#filter(Object, PredicateVisitor)} <br> {@linkplain OperateManager#filter(PredicateVisitor)} * <li>delete method (in iteration): <br> {@linkplain OperateManager#delete(Object, PredicateVisitor)} <br> {@linkplain OperateManager#delete(PredicateVisitor)} * <li>update method (in iteration): <br> {@linkplain OperateManager#update(Object, PredicateVisitor)} <br> {@linkplain OperateManager#update(Object, Object, PredicateVisitor)} * <li> insert method (in iteration, and only support for List): <br> * {@linkplain OperateManager#insert(List, IterateVisitor)}<br> * {@linkplain OperateManager#insert(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, Object, IterateVisitor)} <br> * <li>insert finally method (after iteration ):<br> * {@linkplain OperateManager#insertFinally(List, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, Object, IterateVisitor)}<br> * </ul> * @author heaven7 * * @param <T> the parametric type of most method */
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer; * @param info the IterationInfo. * @return true if intercept success, this means the loop of 'for' will be 'continue'. */ public abstract boolean intercept(Iterator<T> it, T t,@Nullable Object param, IterationInfo info); } /** * The pending operate manager used to support "filter/delete/update/insert" in iteration for all Collection. * and support insert after iteration (before method return). * <ul> * <li>filter method (in iteration): <br> {@linkplain OperateManager#filter(Object, PredicateVisitor)} <br> {@linkplain OperateManager#filter(PredicateVisitor)} * <li>delete method (in iteration): <br> {@linkplain OperateManager#delete(Object, PredicateVisitor)} <br> {@linkplain OperateManager#delete(PredicateVisitor)} * <li>update method (in iteration): <br> {@linkplain OperateManager#update(Object, PredicateVisitor)} <br> {@linkplain OperateManager#update(Object, Object, PredicateVisitor)} * <li> insert method (in iteration, and only support for List): <br> * {@linkplain OperateManager#insert(List, IterateVisitor)}<br> * {@linkplain OperateManager#insert(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, Object, IterateVisitor)} <br> * <li>insert finally method (after iteration ):<br> * {@linkplain OperateManager#insertFinally(List, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, Object, IterateVisitor)}<br> * </ul> * @author heaven7 * * @param <T> the parametric type of most method */
abstract class OperateManager<T> implements Cacheable<OperateManager<T>>,
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // }
import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer;
* @return true if intercept success, this means the loop of 'for' will be 'continue'. */ public abstract boolean intercept(Iterator<T> it, T t,@Nullable Object param, IterationInfo info); } /** * The pending operate manager used to support "filter/delete/update/insert" in iteration for all Collection. * and support insert after iteration (before method return). * <ul> * <li>filter method (in iteration): <br> {@linkplain OperateManager#filter(Object, PredicateVisitor)} <br> {@linkplain OperateManager#filter(PredicateVisitor)} * <li>delete method (in iteration): <br> {@linkplain OperateManager#delete(Object, PredicateVisitor)} <br> {@linkplain OperateManager#delete(PredicateVisitor)} * <li>update method (in iteration): <br> {@linkplain OperateManager#update(Object, PredicateVisitor)} <br> {@linkplain OperateManager#update(Object, Object, PredicateVisitor)} * <li> insert method (in iteration, and only support for List): <br> * {@linkplain OperateManager#insert(List, IterateVisitor)}<br> * {@linkplain OperateManager#insert(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, Object, IterateVisitor)} <br> * <li>insert finally method (after iteration ):<br> * {@linkplain OperateManager#insertFinally(List, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, Object, IterateVisitor)}<br> * </ul> * @author heaven7 * * @param <T> the parametric type of most method */ abstract class OperateManager<T> implements Cacheable<OperateManager<T>>,
// Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Cacheable.java // public interface Cacheable<T> { // // /** // * do cache it. // * @return the original object // * @since 1.1.2 // */ // T cache(); // // /** // * no cache means clear cache. // * @return the original object // * @since 1.1.8 // */ // T noCache(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/Endable.java // public interface Endable<T> { // // /** // * end current and return to the original object // * @return the original object // * @since 1.1.2 // */ // T end(); // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/internal/OperateInterceptor.java // public abstract class OperateInterceptor { // // /** // * begin operate interceptor. // * called before iterate. // */ // public void begin(){ // // } // /** // * end operate interceptor. // * called after iterate. // */ // public void end(){ // // } // // // } // // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Observer.java // public interface Observer<T, R> { // // /** // * called on operate success. // * @param param the extra parameter // * @param r the result when success. // */ // void onSuccess(Object param, R r); // // /** // * called on operate failed. // * @param param the parameter. // * @param t the element when failed. // */ // void onFailed(Object param, T t); // // /** // * called on throwable during visit operation. // * @param param the parameter. // * @param t the element when throwable during visit operation. // * @param e the throwable. // */ // void onThrowable(Object param, T t, Throwable e); // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/CollectionVisitService.java import java.util.Collection; import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import com.heaven7.java.visitor.*; import com.heaven7.java.visitor.anno.DependOn; import com.heaven7.java.visitor.anno.Independence; import com.heaven7.java.visitor.anno.Nullable; import com.heaven7.java.visitor.internal.Cacheable; import com.heaven7.java.visitor.internal.Endable; import com.heaven7.java.visitor.internal.OperateInterceptor; import com.heaven7.java.visitor.util.Observer; * @return true if intercept success, this means the loop of 'for' will be 'continue'. */ public abstract boolean intercept(Iterator<T> it, T t,@Nullable Object param, IterationInfo info); } /** * The pending operate manager used to support "filter/delete/update/insert" in iteration for all Collection. * and support insert after iteration (before method return). * <ul> * <li>filter method (in iteration): <br> {@linkplain OperateManager#filter(Object, PredicateVisitor)} <br> {@linkplain OperateManager#filter(PredicateVisitor)} * <li>delete method (in iteration): <br> {@linkplain OperateManager#delete(Object, PredicateVisitor)} <br> {@linkplain OperateManager#delete(PredicateVisitor)} * <li>update method (in iteration): <br> {@linkplain OperateManager#update(Object, PredicateVisitor)} <br> {@linkplain OperateManager#update(Object, Object, PredicateVisitor)} * <li> insert method (in iteration, and only support for List): <br> * {@linkplain OperateManager#insert(List, IterateVisitor)}<br> * {@linkplain OperateManager#insert(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insert(Object, Object, IterateVisitor)} <br> * <li>insert finally method (after iteration ):<br> * {@linkplain OperateManager#insertFinally(List, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(List, Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, IterateVisitor)}<br> * {@linkplain OperateManager#insertFinally(Object, Object, IterateVisitor)}<br> * </ul> * @author heaven7 * * @param <T> the parametric type of most method */ abstract class OperateManager<T> implements Cacheable<OperateManager<T>>,
Endable<CollectionVisitService<T>>{
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/SynchronizedMap.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // }
import java.util.Collection; import java.util.List; import com.heaven7.java.visitor.collection.KeyValuePair;
@Override public boolean containsKey(K key) { synchronized (mLock) { return mBase.containsKey(key); } } @Override public void clear() { synchronized (mLock) { mBase.clear(); } } @Override public void putAll(Map<? extends K, ? extends V> map) { synchronized (mLock) { mBase.putAll(map); } } @Override public void putAll(java.util.Map<? extends K, ? extends V> map) { synchronized (mLock) { mBase.putAll(map); } } @Override
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/SynchronizedMap.java import java.util.Collection; import java.util.List; import com.heaven7.java.visitor.collection.KeyValuePair; @Override public boolean containsKey(K key) { synchronized (mLock) { return mBase.containsKey(key); } } @Override public void clear() { synchronized (mLock) { mBase.clear(); } } @Override public void putAll(Map<? extends K, ? extends V> map) { synchronized (mLock) { mBase.putAll(map); } } @Override public void putAll(java.util.Map<? extends K, ? extends V> map) { synchronized (mLock) { mBase.putAll(map); } } @Override
public void putPairs(Collection<KeyValuePair<K, V>> pairs) {
LightSun/Visitor
Visitor/src/main/java/com/heaven7/java/visitor/util/Map.java
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // }
import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.Collection; import java.util.ConcurrentModificationException; import java.util.List;
package com.heaven7.java.visitor.util; /** * like traditional map({@linkplain java.util.Map}). but add some useful * methods. * * @author heaven7 * * @param <K> * the key type * @param <V> * the value type. */ public interface Map<K, V> { int size(); void put(K key, V value); void remove(K key); V get(K key); boolean containsKey(K key); void clear(); void putAll(Map<? extends K, ? extends V> map); void putAll(java.util.Map<? extends K, ? extends V> map); /* @since 1.2.0 */
// Path: Visitor/src/main/java/com/heaven7/java/visitor/collection/KeyValuePair.java // public final class KeyValuePair<K, V> { // // private K key; // private V value; // // private KeyValuePair(K key, V value) { // super(); // this.key = key; // this.value = value; // } // // public static <K, V> KeyValuePair<K, V> create(K key, V value) { // return new KeyValuePair<K, V>(key, value); // } // // void setKeyValue(K key, V value) { // this.key = key; // this.value = value; // } // // /** // * set the value. // * // * @param value // * the target value // * @return the old value // */ // // avoid access directly for user. // /* // * V setValue(V value) { // AccessController. return entry.setValue(value); // * } // */ // // /** // * get the key // * // * @return the key // */ // public K getKey() { // return key; // } // // /** // * get the value // * // * @return the value // */ // public V getValue() { // return value; // } // // @Override // public String toString() { // return key + " = " + value; // } // // @SuppressWarnings("unchecked") // @Override // public boolean equals(Object obj) { // if (!(obj instanceof KeyValuePair)) { // return false; // } // final KeyValuePair<K, V> e2; // try { // e2 = (KeyValuePair<K, V>) obj; // } catch (ClassCastException e) { // return false; // } // final KeyValuePair<K, V> e1 = this; // return (e1.getKey() == null ? e2.getKey() == null : e1.getKey().equals(e2.getKey())) // && (e1.getValue() == null ? e2.getValue() == null : e1.getValue().equals(e2.getValue())); // // } // // } // Path: Visitor/src/main/java/com/heaven7/java/visitor/util/Map.java import com.heaven7.java.visitor.collection.KeyValuePair; import java.util.Collection; import java.util.ConcurrentModificationException; import java.util.List; package com.heaven7.java.visitor.util; /** * like traditional map({@linkplain java.util.Map}). but add some useful * methods. * * @author heaven7 * * @param <K> * the key type * @param <V> * the value type. */ public interface Map<K, V> { int size(); void put(K key, V value); void remove(K key); V get(K key); boolean containsKey(K key); void clear(); void putAll(Map<? extends K, ? extends V> map); void putAll(java.util.Map<? extends K, ? extends V> map); /* @since 1.2.0 */
void putPairs(Collection<KeyValuePair<K, V>> pairs);