@Test @SuppressWarnings("unchecked") public void testGet() { Configuration configuration = new Configuration("", ""); Prodigy.configuration(configuration); AmazonDynamoDB dynamoDB = mock(AmazonDynamoDB.class); GetItemResult result = new GetItemResult(); result.setItem(null); doReturn(result).when(dynamoDB).getItem(anyString(), any(Map.class)); Scheduler scheduler = new Scheduler(dynamoDB); Entry entry = scheduler.get("fault-id-1"); assertNull(entry); dynamoDB = mock(AmazonDynamoDB.class); result = new GetItemResult(); result.setItem(new HashMap<>()); doReturn(result).when(dynamoDB).getItem(anyString(), any(Map.class)); scheduler = new Scheduler(dynamoDB); entry = scheduler.get("fault-id-1"); assertNull(entry); dynamoDB = mock(AmazonDynamoDB.class); result = new GetItemResult(); Map<String, AttributeValue> item = new HashMap<>(); item.put("id", new AttributeValue("fault-id-2")); item.put("name", new AttributeValue("fault-2")); item.put("status", new AttributeValue("ACTIVE")); item.put("params", new AttributeValue("{}")); result.setItem(item); doReturn(result).when(dynamoDB).getItem(anyString(), any(Map.class)); scheduler = new Scheduler(dynamoDB); entry = scheduler.get("fault-id-2"); assertThat(entry.getId(), is("fault-id-2")); assertThat(entry.getName(), is("fault-2")); assertThat(entry.getStatus(), is("ACTIVE")); assertThat(entry.getParams(), is("{}")); }
public Entry get(String id) { Map<String, AttributeValue> key = new HashMap<>(); key.put("id", new AttributeValue().withS(id)); GetItemResult result = dynamoDB.getItem(Prodigy.configuration().scheduler(), key); Map<String, AttributeValue> item = result.getItem(); if (item == null || item.isEmpty()) { return null; } Entry entry = new Entry(item.get("id").getS(), item.get("name").getS(), item.get("status").getS(), item.get("params").getS()); return entry; }
Scheduler { public Entry get(String id) { Map<String, AttributeValue> key = new HashMap<>(); key.put("id", new AttributeValue().withS(id)); GetItemResult result = dynamoDB.getItem(Prodigy.configuration().scheduler(), key); Map<String, AttributeValue> item = result.getItem(); if (item == null || item.isEmpty()) { return null; } Entry entry = new Entry(item.get("id").getS(), item.get("name").getS(), item.get("status").getS(), item.get("params").getS()); return entry; } }
Scheduler { public Entry get(String id) { Map<String, AttributeValue> key = new HashMap<>(); key.put("id", new AttributeValue().withS(id)); GetItemResult result = dynamoDB.getItem(Prodigy.configuration().scheduler(), key); Map<String, AttributeValue> item = result.getItem(); if (item == null || item.isEmpty()) { return null; } Entry entry = new Entry(item.get("id").getS(), item.get("name").getS(), item.get("status").getS(), item.get("params").getS()); return entry; } Scheduler();  Scheduler(AmazonDynamoDB dynamoDB); }
Scheduler { public Entry get(String id) { Map<String, AttributeValue> key = new HashMap<>(); key.put("id", new AttributeValue().withS(id)); GetItemResult result = dynamoDB.getItem(Prodigy.configuration().scheduler(), key); Map<String, AttributeValue> item = result.getItem(); if (item == null || item.isEmpty()) { return null; } Entry entry = new Entry(item.get("id").getS(), item.get("name").getS(), item.get("status").getS(), item.get("params").getS()); return entry; } Scheduler();  Scheduler(AmazonDynamoDB dynamoDB); boolean schedule(Fault fault); boolean unschedule(String id); Entry get(String id); List<Entry> list(); }
Scheduler { public Entry get(String id) { Map<String, AttributeValue> key = new HashMap<>(); key.put("id", new AttributeValue().withS(id)); GetItemResult result = dynamoDB.getItem(Prodigy.configuration().scheduler(), key); Map<String, AttributeValue> item = result.getItem(); if (item == null || item.isEmpty()) { return null; } Entry entry = new Entry(item.get("id").getS(), item.get("name").getS(), item.get("status").getS(), item.get("params").getS()); return entry; } Scheduler();  Scheduler(AmazonDynamoDB dynamoDB); boolean schedule(Fault fault); boolean unschedule(String id); Entry get(String id); List<Entry> list();  }