@Test public void createAssociation() throws Exception { assertNotNull(objectAssociationAPIController.getObjectAssociationService()); String content = "{\"@id\":\"1\",\"parentId\":105,\"parentType\":\"PERSON\",\"parentClassName\":\"com.armedia.acm.plugins.person.model.Person\",\"targetId\":101,\"targetType\":\"PERSON\",\"targetClassName\":\"com.armedia.acm.plugins.person.model.Person\",\"associationType\":\"Sibling\",\"inverseAssociation\":{\"@id\":\"2\",\"parentId\":101,\"parentType\":\"PERSON\",\"parentClassName\":\"com.armedia.acm.plugins.person.model.Person\",\"targetId\":105,\"targetType\":\"PERSON\",\"targetClassName\":\"com.armedia.acm.plugins.person.model.Person\",\"associationType\":\"Sibling\",\"inverseAssociation\":{\"@ref\":\"1\"}}}"; when(objectAssociationDao.save(anyObject())).then(invocationOnMock -> invocationOnMock.getArguments()[0]); MvcResult result = mockMvc.perform( post("/api/latest/service/objectassociations") .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .content(content).principal(mockAuthentication)) .andExpect(status().isOk()) .andReturn(); log.info("Results: " + result.getResponse().getContentAsString()); ObjectMapper om = new ObjectMapper(); ObjectAssociation objectAssociation = om.readValue(result.getResponse().getContentAsByteArray(), ObjectAssociation.class); assertNotNull(objectAssociation.getInverseAssociation()); ObjectAssociation inverseAssociation = objectAssociation.getInverseAssociation(); assertEquals(objectAssociation.getTargetId(), inverseAssociation.getParentId()); assertEquals(objectAssociation.getTargetType(), inverseAssociation.getParentType()); assertEquals(HttpStatus.OK.value(), result.getResponse().getStatus()); }
public ObjectAssociationService getObjectAssociationService() { return objectAssociationService; }
ObjectAssociationAPIController { public ObjectAssociationService getObjectAssociationService() { return objectAssociationService; } }
ObjectAssociationAPIController { public ObjectAssociationService getObjectAssociationService() { return objectAssociationService; }  }
ObjectAssociationAPIController { public ObjectAssociationService getObjectAssociationService() { return objectAssociationService; }  @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) String getObjectAssociations(Authentication auth, @RequestParam(value = "parent-id") Long parentId,
            @RequestParam(value = "parent-type", required = false) String parentType,
            @RequestParam(value = "target-type", required = false) String targetType,
            @RequestParam(value = "order-by", required = false) String orderBy,
            @RequestParam(value = "start", required = false, defaultValue = "0") int start,
            @RequestParam(value = "n", required = false, defaultValue = "10") int n); @RequestMapping(method = RequestMethod.DELETE, value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) void deleteAssociation(@PathVariable Long id, Authentication auth); @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) ObjectAssociation saveAssociation(@RequestBody ObjectAssociation objectAssociation, Authentication auth); @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ObjectAssociation getAssociation(@PathVariable Long id, Authentication auth); ObjectAssociationService getObjectAssociationService(); void setObjectAssociationService(ObjectAssociationService objectAssociationService); }
ObjectAssociationAPIController { public ObjectAssociationService getObjectAssociationService() { return objectAssociationService; }  @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) String getObjectAssociations(Authentication auth, @RequestParam(value = "parent-id") Long parentId,
            @RequestParam(value = "parent-type", required = false) String parentType,
            @RequestParam(value = "target-type", required = false) String targetType,
            @RequestParam(value = "order-by", required = false) String orderBy,
            @RequestParam(value = "start", required = false, defaultValue = "0") int start,
            @RequestParam(value = "n", required = false, defaultValue = "10") int n); @RequestMapping(method = RequestMethod.DELETE, value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.OK) void deleteAssociation(@PathVariable Long id, Authentication auth); @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) ObjectAssociation saveAssociation(@RequestBody ObjectAssociation objectAssociation, Authentication auth); @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) ObjectAssociation getAssociation(@PathVariable Long id, Authentication auth); ObjectAssociationService getObjectAssociationService(); void setObjectAssociationService(ObjectAssociationService objectAssociationService);  }