/** * {@inheritDoc} */ @Override public Profile importProfile(Profile profile) throws BusinessException { try { return ciManager.importProfile(profile); } catch (JAXBException e) { throw new TechnicalException("Import the profile '" + profile.getName() + "'.", ConfigurationInterfaceErrorCodeEnum.JAXB_MARSHALLING_OR_DEMARSHALLING_FAILED, e); } catch (IOException e) { throw new TechnicalException("Import the profile '" + profile.getName() + "'.", ConfigurationInterfaceErrorCodeEnum.INPUT_OUTPUT_OPERATION_FAILED, e); } }
@Test(expectedExceptions = BusinessException.class) public void importProfileNoId() throws Exception { Profile profile = new Profile(); profile.setName("test"); manager.importProfile(profile); }
@Test public void importProfile() throws Exception { Profile profile = new Profile(); profile.setId("myId"); profile.setName("test"); manager.importProfile(profile); assertThat(profile.getId(), is("myId")); assertThat(profile.getImportDate(), is(not(nullValue()))); assertThat(manager.getAllProfiles(), hasItem(profile)); }
@Test public void importProfileExists() throws Exception { Profile profile = new Profile(); profile.setName("test"); profile.setProfileData(new SensorAssignmentProfileData()); manager.createProfile(profile); Profile importProfile = new Profile(); importProfile.setId(profile.getId()); importProfile.setName("imported"); manager.importProfile(importProfile); assertThat(manager.getProfile(profile.getId()), is(importProfile)); }