Skip to content

Commit

Permalink
Remove TargetInfo entity (#453)
Browse files Browse the repository at this point in the history
Signed-off-by: kaizimmerm <[email protected]>
  • Loading branch information
kaizimmerm authored Mar 17, 2017
1 parent 67d17fe commit 602fb78
Show file tree
Hide file tree
Showing 89 changed files with 1,164 additions and 1,460 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ public enum TargetFields implements FieldNameProvider {
/**
* The updateStatus field.
*/
UPDATESTATUS("targetInfo.updateStatus"),
UPDATESTATUS("updateStatus"),

/**
* The ip-address field.
*/
IPADDRESS("targetInfo.address"),
IPADDRESS("address"),

/**
* The attribute map of target info.
*/
ATTRIBUTE("targetInfo.controllerAttributes", true),
ATTRIBUTE("controllerAttributes", true),

/**
* distribution sets which is assigned to the target.
Expand All @@ -67,17 +67,17 @@ public enum TargetFields implements FieldNameProvider {
/**
* distribution sets which is installed on the target.
*/
INSTALLEDDS("targetInfo.installedDistributionSet", "name", "version"),
INSTALLEDDS("installedDistributionSet", "name", "version"),

/**
* The tags field.
*/
TAG("tags.name"),

/**
* Last time the target or DMF client polled.
* Last time the DDI or DMF client polled.
*/
LASTCONTROLLERREQUESTAT("targetInfo.lastTargetQuery");
LASTCONTROLLERREQUESTAT("lastTargetQuery");

private final String fieldName;
private List<String> subEntityAttribues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static DdiControllerBase fromTarget(final Target target, final Action action,
}
}

if (target.getTargetInfo().isRequestControllerAttributes()) {
if (target.isRequestControllerAttributes()) {
result.add(ControllerLinkBuilder
.linkTo(ControllerLinkBuilder.methodOn(DdiRootController.class, tenantAware.getCurrentTenant())
.putConfigData(null, tenantAware.getCurrentTenant(), target.getControllerId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ public void rootRsCancelActionButContinueAnyway() throws Exception {
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());

// check database after test
assertThat(deploymentManagement.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
.isEqualTo(ds);
assertThat(deploymentManagement.getInstalledDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
.isEqualTo(ds);
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getAssignedDistributionSet().getId()).isEqualTo(ds.getId());
assertThat(targetManagement.findTargetByControllerIDWithDetails(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getInstalledDistributionSet().getId()).isEqualTo(ds.getId());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getInstallationDate()).isGreaterThanOrEqualTo(current);
.getInstallationDate()).isGreaterThanOrEqualTo(current);

}

Expand All @@ -119,9 +119,9 @@ public void rootRsCancelAction() throws Exception {
// often too fast and
// the following assert will fail
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);

// Retrieved is reported

Expand Down Expand Up @@ -151,23 +151,23 @@ public void rootRsCancelAction() throws Exception {
// often too fast and
// the following assert will fail
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);

current = System.currentTimeMillis();
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.id", equalTo(String.valueOf(cancelAction.getId()))))
.andExpect(jsonPath("$.cancelAction.stopId", equalTo(String.valueOf(updateAction.getId()))));
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
.getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);

// controller confirmed cancelled action, should not be active anymore
mvc.perform(post("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
Expand Down Expand Up @@ -251,7 +251,7 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);

assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(3);
Expand All @@ -263,7 +263,7 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(4);

Expand All @@ -274,7 +274,7 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(5);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);

Expand All @@ -287,7 +287,7 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(6);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);

Expand All @@ -303,7 +303,7 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(7);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);

Expand All @@ -315,7 +315,7 @@ public void rootRsCancelActionFeedback() throws Exception {
.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current);
.getLastTargetQuery()).isGreaterThanOrEqualTo(current);
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(8);
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(0);
}
Expand Down Expand Up @@ -403,8 +403,8 @@ public void multipleCancelActionFeedback() throws Exception {
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk());
assertThat(deploymentManagement.countActionStatusAll()).isEqualTo(9);

assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getAssignedDistributionSet()).isEqualTo(ds3);
assertThat(deploymentManagement.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
.isEqualTo(ds3);
mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/deploymentBase/"
+ updateAction3.getId(), tenantAware.getCurrentTenant())).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());
Expand All @@ -418,8 +418,8 @@ public void multipleCancelActionFeedback() throws Exception {
// action is in cancelling state
assertThat(deploymentManagement.findActiveActionsByTarget(savedTarget.getControllerId())).hasSize(1);
assertThat(deploymentManagement.countActionsByTarget(savedTarget.getControllerId())).isEqualTo(3);
assertThat(targetManagement.findTargetByControllerID(TestdataFactory.DEFAULT_CONTROLLER_ID).get()
.getAssignedDistributionSet()).isEqualTo(ds3);
assertThat(deploymentManagement.getAssignedDistributionSet(TestdataFactory.DEFAULT_CONTROLLER_ID).get())
.isEqualTo(ds3);

mvc.perform(get("/{tenant}/controller/v1/" + TestdataFactory.DEFAULT_CONTROLLER_ID + "/cancelAction/"
+ cancelAction3.getId(), tenantAware.getCurrentTenant()).accept(MediaType.APPLICATION_JSON))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;

import com.google.common.collect.Maps;

import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
Expand Down Expand Up @@ -58,19 +60,20 @@ public void requestConfigDataIfEmpty() throws Exception {
Thread.sleep(1); // is required: otherwise processing the next line is
// often too fast and
// the following assert will fail
assertThat(targetManagement.findTargetByControllerID("4712").get().getTargetInfo().getLastTargetQuery())
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
.isLessThanOrEqualTo(System.currentTimeMillis());
assertThat(targetManagement.findTargetByControllerID("4712").get().getTargetInfo().getLastTargetQuery())
assertThat(targetManagement.findTargetByControllerID("4712").get().getLastTargetQuery())
.isGreaterThanOrEqualTo(current);

savedTarget.getTargetInfo().getControllerAttributes().put("dsafsdf", "sdsds");
final Map<String, String> attributes = Maps.newHashMapWithExpectedSize(1);
attributes.put("dsafsdf", "sdsds");

final Target updateControllerAttributes = controllerManagement.updateControllerAttributes(
savedTarget.getControllerId(), savedTarget.getTargetInfo().getControllerAttributes());
final Target updateControllerAttributes = controllerManagement
.updateControllerAttributes(savedTarget.getControllerId(), attributes);
// request controller attributes need to be false because we don't want
// to request the
// controller attributes again
assertThat(updateControllerAttributes.getTargetInfo().isRequestControllerAttributes()).isFalse();
assertThat(updateControllerAttributes.isRequestControllerAttributes()).isFalse();

mvc.perform(
get("/{tenant}/controller/v1/4712", tenantAware.getCurrentTenant()).accept(APPLICATION_JSON_HAL_UTF))
Expand All @@ -97,12 +100,11 @@ public void putConfigData() throws Exception {
Thread.sleep(1); // is required: otherwise processing the next line is
// often too fast and
// the following assert will fail
assertThat(targetManagement.findTargetByControllerID("4717").get().getTargetInfo().getLastTargetQuery())
assertThat(targetManagement.findTargetByControllerID("4717").get().getLastTargetQuery())
.isLessThanOrEqualTo(System.currentTimeMillis());
assertThat(targetManagement.findTargetByControllerID("4717").get().getTargetInfo().getLastTargetQuery())
assertThat(targetManagement.findTargetByControllerID("4717").get().getLastTargetQuery())
.isGreaterThanOrEqualTo(current);
assertThat(targetManagement.findTargetByControllerIDWithDetails("4717").get().getTargetInfo()
.getControllerAttributes()).isEqualTo(attributes);
assertThat(targetManagement.getControllerAttributes("4717")).isEqualTo(attributes);

// update
attributes.put("sdsds", "123412");
Expand All @@ -113,12 +115,11 @@ public void putConfigData() throws Exception {
Thread.sleep(1); // is required: otherwise processing the next line is
// often too fast and
// the following assert will fail
assertThat(targetManagement.findTargetByControllerID("4717").get().getTargetInfo().getLastTargetQuery())
assertThat(targetManagement.findTargetByControllerID("4717").get().getLastTargetQuery())
.isLessThanOrEqualTo(System.currentTimeMillis());
assertThat(targetManagement.findTargetByControllerID("4717").get().getTargetInfo().getLastTargetQuery())
assertThat(targetManagement.findTargetByControllerID("4717").get().getLastTargetQuery())
.isGreaterThanOrEqualTo(current);
assertThat(targetManagement.findTargetByControllerIDWithDetails("4717").get().getTargetInfo()
.getControllerAttributes()).isEqualTo(attributes);
assertThat(targetManagement.getControllerAttributes("4717")).isEqualTo(attributes);
}

@Test
Expand Down
Loading

0 comments on commit 602fb78

Please sign in to comment.