/** * Creates a new namespace. * * @param request the information needed to create the namespace * * @return the created namespace */ @RequestMapping(value = "/namespaces", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_NAMESPACES_POST) public Namespace createNamespace(@RequestBody NamespaceCreateRequest request) { return namespaceService.createNamespace(request); }
/** * Deletes an existing namespace by namespace code. * * @param namespaceCode the namespace code * * @return the namespace that got deleted */ @RequestMapping(value = "/namespaces/{namespaceCode}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_NAMESPACES_DELETE) public Namespace deleteNamespace(@PathVariable("namespaceCode") String namespaceCode) { return namespaceService.deleteNamespace(new NamespaceKey(namespaceCode)); }
/** * Gets an existing namespace by namespace code. * * @param namespaceCode the namespace code * * @return the retrieved namespace */ @RequestMapping(value = "/namespaces/{namespaceCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_NAMESPACES_GET) public Namespace getNamespace(@PathVariable("namespaceCode") String namespaceCode) { return namespaceService.getNamespace(new NamespaceKey(namespaceCode)); }
/** * Gets a list of namespace keys for all namespaces defined in the system. * * @return the list of namespace keys */ @RequestMapping(value = "/namespaces", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_NAMESPACES_ALL_GET) public NamespaceKeys getNamespaces() { return namespaceService.getNamespaces(); } }
/** * Gets a list of namespace keys for all namespaces defined in the system. * * @return the list of namespace keys */ @RequestMapping(value = "/namespaces", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_NAMESPACES_ALL_GET) public NamespaceKeys getNamespaces() { return namespaceService.getNamespaces(); } }
/** * Creates a new namespace. * * @param request the information needed to create the namespace * * @return the created namespace */ @RequestMapping(value = "/namespaces", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_NAMESPACES_POST) public Namespace createNamespace(@RequestBody NamespaceCreateRequest request) { return namespaceService.createNamespace(request); }
/** * Gets an existing namespace by namespace code. * * @param namespaceCode the namespace code * * @return the retrieved namespace */ @RequestMapping(value = "/namespaces/{namespaceCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_NAMESPACES_GET) public Namespace getNamespace(@PathVariable("namespaceCode") String namespaceCode) { return namespaceService.getNamespace(new NamespaceKey(namespaceCode)); }
/** * Deletes an existing namespace by namespace code. * * @param namespaceCode the namespace code * * @return the namespace that got deleted */ @RequestMapping(value = "/namespaces/{namespaceCode}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_NAMESPACES_DELETE) public Namespace deleteNamespace(@PathVariable("namespaceCode") String namespaceCode) { return namespaceService.deleteNamespace(new NamespaceKey(namespaceCode)); }
@Test public void testGetNamespaces() throws Exception { NamespaceKeys namespaceKeys = new NamespaceKeys(Arrays.asList(new NamespaceKey(NAMESPACE), new NamespaceKey(NAMESPACE_2))); when(namespaceService.getNamespaces()).thenReturn(namespaceKeys); // Retrieve a list of namespace keys. NamespaceKeys resultNamespaceKeys = namespaceRestController.getNamespaces(); // Verify the external calls. verify(namespaceService).getNamespaces(); verifyNoMoreInteractions(namespaceService); // Validate the returned object. assertEquals(namespaceKeys, resultNamespaceKeys); } }
@Test public void testCreateNamespaceLowerCaseParameters() { // Create a namespace using lower case input parameters. Namespace resultNamespace = namespaceService.createNamespace(namespaceServiceTestHelper.createNamespaceCreateRequest(NAMESPACE.toLowerCase())); // Validate the returned object. namespaceServiceTestHelper.validateNamespace(NAMESPACE.toLowerCase(), resultNamespace); }
@Test public void testGetNamespaceUpperCaseParameters() { // Create and persist a namespace entity using lower case values. namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toLowerCase()); // Retrieve the namespace using upper case input parameters. Namespace resultNamespace = namespaceService.getNamespace(new NamespaceKey(NAMESPACE.toUpperCase())); // Validate the returned object. namespaceServiceTestHelper.validateNamespace(NAMESPACE.toLowerCase(), resultNamespace); }
@Test public void testDeleteNamespace() throws Exception { Namespace namespace = new Namespace(NAMESPACE); when(namespaceService.deleteNamespace(new NamespaceKey(NAMESPACE))).thenReturn(namespace); // Delete this namespace. Namespace deletedNamespace = namespaceRestController.deleteNamespace(NAMESPACE); // Verify the external calls. verify(namespaceService).deleteNamespace(new NamespaceKey(NAMESPACE)); verifyNoMoreInteractions(namespaceService); // Validate the returned object. assertEquals(namespace, deletedNamespace); }
@Test public void testGetNamespaces() throws Exception { // Create and persist namespace entities. for (NamespaceKey key : namespaceDaoTestHelper.getTestNamespaceKeys()) { namespaceDaoTestHelper.createNamespaceEntity(key.getNamespaceCode()); } // Retrieve a list of namespace keys. NamespaceKeys resultNamespaceKeys = namespaceService.getNamespaces(); // Validate the returned object. assertNotNull(resultNamespaceKeys); assertNotNull(resultNamespaceKeys.getNamespaceKeys()); assertTrue(resultNamespaceKeys.getNamespaceKeys().size() >= namespaceDaoTestHelper.getTestNamespaceKeys().size()); for (NamespaceKey key : namespaceDaoTestHelper.getTestNamespaceKeys()) { assertTrue(resultNamespaceKeys.getNamespaceKeys().contains(key)); } }
@Test public void testCreateNamespaceUpperCaseParameters() { // Create a namespace using upper case input parameters. Namespace resultNamespace = namespaceService.createNamespace(namespaceServiceTestHelper.createNamespaceCreateRequest(NAMESPACE.toUpperCase())); // Validate the returned object. namespaceServiceTestHelper.validateNamespace(NAMESPACE.toUpperCase(), resultNamespace); }
@Test public void testGetNamespace() throws Exception { Namespace namespace = new Namespace(NAMESPACE); when(namespaceService.getNamespace(new NamespaceKey(NAMESPACE))).thenReturn(namespace); // Retrieve the namespace. Namespace resultNamespace = namespaceRestController.getNamespace(NAMESPACE); // Verify the external calls. verify(namespaceService).getNamespace(new NamespaceKey(NAMESPACE)); verifyNoMoreInteractions(namespaceService); // Validate the returned object. assertEquals(namespace, resultNamespace); }
@Test public void testDeleteNamespaceMissingRequiredParameters() { // Try to delete a namespace instance when namespace code is not specified. try { namespaceService.deleteNamespace(new NamespaceKey(BLANK_TEXT)); fail("Should throw an IllegalArgumentException when namespace code is not specified."); } catch (IllegalArgumentException e) { assertEquals("A namespace must be specified.", e.getMessage()); } }
@Test public void testCreateNamespace() throws Exception { NamespaceCreateRequest request = namespaceServiceTestHelper.createNamespaceCreateRequest(NAMESPACE); Namespace namespace = new Namespace(NAMESPACE); when(namespaceService.createNamespace(request)).thenReturn(namespace); // Create a namespace. Namespace resultNamespace = namespaceRestController.createNamespace(request); // Validate the returned object. namespaceServiceTestHelper.validateNamespace(NAMESPACE, resultNamespace); // Verify the external calls. verify(namespaceService).createNamespace(request); verifyNoMoreInteractions(namespaceService); // Validate the returned object. assertEquals(namespace, resultNamespace); }
@Test public void testGetNamespaceLowerCaseParameters() { // Create and persist a namespace entity using upper case values. namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toUpperCase()); // Retrieve the namespace using lower case input parameters. Namespace resultNamespace = namespaceService.getNamespace(new NamespaceKey(NAMESPACE.toLowerCase())); // Validate the returned object. namespaceServiceTestHelper.validateNamespace(NAMESPACE.toUpperCase(), resultNamespace); }
@Test public void testDeleteNamespaceUpperCaseParameters() { // Create and persist a namespace entity using lower case values. namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE.toLowerCase()); // Validate that this namespace exists. NamespaceKey namespaceKey = new NamespaceKey(NAMESPACE.toLowerCase()); assertNotNull(namespaceDao.getNamespaceByKey(namespaceKey)); // Delete this namespace using upper case input parameters. Namespace deletedNamespace = namespaceService.deleteNamespace(new NamespaceKey(NAMESPACE.toUpperCase())); // Validate the returned object. namespaceServiceTestHelper.validateNamespace(NAMESPACE.toLowerCase(), deletedNamespace); // Ensure that this namespace is no longer there. assertNull(namespaceDao.getNamespaceByKey(namespaceKey)); }
@Test public void testCreateNamespace() throws Exception { // Create a namespace. Namespace resultNamespace = namespaceService.createNamespace(namespaceServiceTestHelper.createNamespaceCreateRequest(NAMESPACE)); // Validate the returned object. namespaceServiceTestHelper.validateNamespace(NAMESPACE, resultNamespace); }