Skip to content

Commit

Permalink
Merge pull request #1 from ihudak/workitem
Browse files Browse the repository at this point in the history
Workitem
  • Loading branch information
ihudak authored Feb 2, 2025
2 parents 9077974 + a7559c0 commit 30f5c29
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion workitems/load-test-curl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ b=""
c="content"
while [ "$b" != "$c" ];
do
a=$(curl -s http://<server>/api/users/api/v1/users);
a=$(curl -s http://<server>/api/workitems/api/v1/workitems);
#b=${a:2:7};
echo $a;
done
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import eu.dec21.wp.model.Version;
import eu.dec21.wp.workitems.service.WorkItemService;
import eu.dec21.wp.workitems.service.impl.WorkItemServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -18,8 +19,7 @@
@RestController
@RequestMapping("/api/v1/version")
public class VersionController {
@Autowired
private WorkItemService workItemService;
private final WorkItemService workItemService = new WorkItemServiceImpl();
@Value("${application.version}")
private String svcVer;
@Value("${application.date}")
Expand Down
26 changes: 13 additions & 13 deletions workitems/src/main/java/eu/dec21/wp/workitems/entity/WorkItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import com.github.javafaker.Address;
import lombok.*;
import com.github.javafaker.Faker;
import java.util.Random;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class WorkItem {

private static Faker faker = new Faker();
private static Random random = new Random();

private long id;

Expand All @@ -34,23 +35,22 @@ public class WorkItem {

public static WorkItem generateWorkItem() {
WorkItem workItem = new WorkItem();
workItem.setId(faker.random().nextLong());
workItem.setName(faker.app().name());
workItem.setDescription(faker.book().title());
Address address = faker.address();
workItem.setCountry(address.country());
workItem.setCity(address.city());
workItem.setAddress(address.fullAddress());
workItem.setAssignee(address.lastName() + " " + address.firstName());
workItem.setPoints(faker.number().numberBetween(1, 100));
workItem.setCost(faker.random().nextDouble());
workItem.setBlocked(faker.bool().bool());
workItem.setId(random.nextLong());
workItem.setName("Name" + random.nextLong());
workItem.setDescription("Description" + random.nextLong());
workItem.setCountry("Country" + random.nextLong());
workItem.setCity("City" + random.nextLong());
workItem.setAddress("Address" + random.nextLong());
workItem.setAssignee("Assignee" + random.nextLong());
workItem.setPoints(random.nextInt(100));
workItem.setCost(random.nextDouble());
workItem.setBlocked(random.nextBoolean());
return workItem;
}

public long generateId() {
if ( id == 0) {
id = faker.random().nextLong();
id = random.nextLong();
}
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@

@Repository
public class WorkItemRepository {
@Value("${workitems.count}")
private String wrkItemCount;

private ArrayList<WorkItem> workItems;

private Logger logger = LoggerFactory.getLogger(WorkItemRepository.class);
final private Logger logger = LoggerFactory.getLogger(WorkItemRepository.class);

WorkItemRepository(@Value("${workitems.count}") int wkrItmCnt) {
workItems = new ArrayList<>(wkrItmCnt);
for (int i = 0; i < wkrItmCnt; i++) {
public WorkItemRepository() {
int workItemCount;
try {
workItemCount = Integer.parseInt(this.wrkItemCount);
} catch (NumberFormatException e) {
workItemCount = 100;
}
workItems = new ArrayList<>(workItemCount);
for (int i = 0; i < workItemCount; i++) {
workItems.add(WorkItem.generateWorkItem());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import eu.dec21.wp.workitems.repository.WorkItemRepository;
import eu.dec21.wp.workitems.service.WorkItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class WorkItemServiceImpl implements WorkItemService {
@Autowired
private WorkItemRepository workItemRepository;
private WorkItemRepository workItemRepository = new WorkItemRepository();


@Override
Expand Down

0 comments on commit 30f5c29

Please sign in to comment.