Problem Statement
Design a customer issue resolution system where customers can raise issues related to products or services, and support agents can resolve them within a defined lifecycle. The system should ensure proper assignment, tracking, and status updates until the issue is fully resolved.
Functional Requirements
- Customers should be able to raise issues
- Each issue should have a lifecycle (OPEN → IN_PROGRESS → RESOLVED → CLOSED)
- Issues should be assigned to support agents
- Agents should update issue status
- System should support priority levels
- Issues should maintain full history of resolution flow
Objects Required
- Customer
- SupportAgent
- Issue
- IssueService
- IssueStatus Enum
- Priority Enum
IssueStatus Enum
public enum IssueStatus {
OPEN,
IN_PROGRESS,
RESOLVED,
CLOSED
}
This enum defines the lifecycle of an issue and ensures consistent state transitions instead of free-form strings.
Priority Enum
public enum Priority {
LOW,
MEDIUM,
HIGH,
CRITICAL
}
Priority helps the system decide urgency and SLA handling for each issue.
Customer Class
public class Customer {
private String customerId;
private String name;
public Customer(String customerId, String name) {
this.customerId = customerId;
this.name = name;
}
public String getName() {
return name;
}
}
Customer represents a user who can raise issues in the system.
SupportAgent Class
public class SupportAgent {
private String agentId;
private String name;
public SupportAgent(String agentId, String name) {
this.agentId = agentId;
this.name = name;
}
public String getName() {
return name;
}
}
SupportAgent represents a service executive responsible for resolving customer issues.
Issue Class
import java.util.*;
public class Issue {
private String issueId;
private String description;
private Customer customer;
private SupportAgent assignedAgent;
private IssueStatus status;
private Priority priority;
private List history;
public Issue(String issueId, String description, Customer customer, Priority priority) {
this.issueId = issueId;
this.description = description;
this.customer = customer;
this.priority = priority;
this.status = IssueStatus.OPEN;
this.history = new ArrayList<>();
this.history.add("Issue created");
}
public void assignAgent(SupportAgent agent) {
this.assignedAgent = agent;
this.status = IssueStatus.IN_PROGRESS;
history.add("Assigned to agent: " + agent.getName());
}
public void resolveIssue() {
this.status = IssueStatus.RESOLVED;
history.add("Issue resolved");
}
public void closeIssue() {
this.status = IssueStatus.CLOSED;
history.add("Issue closed");
}
public List getHistory() {
return history;
}
}
The Issue class is the core entity that tracks problem details, customer info, agent assignment, status, and full lifecycle history.
The constructor initializes a new issue in OPEN state and records its creation in history.
The assignAgent() method assigns a support agent and moves the issue into IN_PROGRESS state.
The resolveIssue() method marks the issue as RESOLVED and records the action.
The closeIssue() method finalizes the issue lifecycle.
IssueService Class
import java.util.*;
public class IssueService {
private Map issueStore = new HashMap<>();
public void createIssue(Issue issue) {
issueStore.put(issue.toString(), issue);
}
public void assignIssue(String issueId, SupportAgent agent) {
for (Issue issue : issueStore.values()) {
if (issue.toString().equals(issueId)) {
issue.assignAgent(agent);
}
}
}
public void resolveIssue(String issueId) {
for (Issue issue : issueStore.values()) {
if (issue.toString().equals(issueId)) {
issue.resolveIssue();
}
}
}
public void closeIssue(String issueId) {
for (Issue issue : issueStore.values()) {
if (issue.toString().equals(issueId)) {
issue.closeIssue();
}
}
}
}
IssueService acts as the orchestration layer that manages issue lifecycle operations like creation, assignment, resolution, and closure.
It maintains an in-memory store of issues for quick retrieval and updates.
Main Class
public class Main {
public static void main(String[] args) {
Customer customer = new Customer("C1", "Alice");
SupportAgent agent = new SupportAgent("A1", "John");
Issue issue = new Issue(
"I1",
"Payment not processed",
customer,
Priority.HIGH
);
IssueService service = new IssueService();
service.createIssue(issue);
service.assignIssue("I1", agent);
service.resolveIssue("I1");
service.closeIssue("I1");
System.out.println(issue.getHistory());
}
}
Comments
Post a Comment