@Test public void createAssetGroupDetailsIncludeTest() throws PacManException, IOException { CreateUpdateAssetGroupDetails createUpdateAssetGroupDetails = getCreateUpdateAssetGroupDetailsRequest(true, 1); HttpEntity jsonEntity = new StringEntity("{}", ContentType.APPLICATION_JSON); when(response.getEntity()).thenReturn(jsonEntity); when(commonService.invokeAPI(anyString(), anyString(), anyString())).thenReturn(response); when(sl.getStatusCode()).thenReturn(200); when(response.getStatusLine()).thenReturn(sl); assertThat(assetGroupService.createAssetGroupDetails(createUpdateAssetGroupDetails, StringUtils.EMPTY), is(notNullValue())); }
@Override public String createAssetGroupDetails(final CreateUpdateAssetGroupDetails createAssetGroupDetails, final String userId) throws PacManException { try { Map<String, Object> assetGroupAlias = createAliasForAssetGroup(createAssetGroupDetails); Response response = commonService.invokeAPI("POST", ALIASES, mapper.writeValueAsString(assetGroupAlias)); if(response != null) { if (response.getStatusLine().getStatusCode() == 200) { return processCreateAssetGroupDetails(createAssetGroupDetails, assetGroupAlias, userId); } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); throw new PacManException(UNEXPECTED_ERROR_OCCURRED.concat(": ").concat(exception.getMessage())); } }
AssetGroupServiceImpl implements AssetGroupService { @Override public String createAssetGroupDetails(final CreateUpdateAssetGroupDetails createAssetGroupDetails, final String userId) throws PacManException { try { Map<String, Object> assetGroupAlias = createAliasForAssetGroup(createAssetGroupDetails); Response response = commonService.invokeAPI("POST", ALIASES, mapper.writeValueAsString(assetGroupAlias)); if(response != null) { if (response.getStatusLine().getStatusCode() == 200) { return processCreateAssetGroupDetails(createAssetGroupDetails, assetGroupAlias, userId); } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); throw new PacManException(UNEXPECTED_ERROR_OCCURRED.concat(": ").concat(exception.getMessage())); } } }
AssetGroupServiceImpl implements AssetGroupService { @Override public String createAssetGroupDetails(final CreateUpdateAssetGroupDetails createAssetGroupDetails, final String userId) throws PacManException { try { Map<String, Object> assetGroupAlias = createAliasForAssetGroup(createAssetGroupDetails); Response response = commonService.invokeAPI("POST", ALIASES, mapper.writeValueAsString(assetGroupAlias)); if(response != null) { if (response.getStatusLine().getStatusCode() == 200) { return processCreateAssetGroupDetails(createAssetGroupDetails, assetGroupAlias, userId); } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); throw new PacManException(UNEXPECTED_ERROR_OCCURRED.concat(": ").concat(exception.getMessage())); } }  }
AssetGroupServiceImpl implements AssetGroupService { @Override public String createAssetGroupDetails(final CreateUpdateAssetGroupDetails createAssetGroupDetails, final String userId) throws PacManException { try { Map<String, Object> assetGroupAlias = createAliasForAssetGroup(createAssetGroupDetails); Response response = commonService.invokeAPI("POST", ALIASES, mapper.writeValueAsString(assetGroupAlias)); if(response != null) { if (response.getStatusLine().getStatusCode() == 200) { return processCreateAssetGroupDetails(createAssetGroupDetails, assetGroupAlias, userId); } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); throw new PacManException(UNEXPECTED_ERROR_OCCURRED.concat(": ").concat(exception.getMessage())); } }  @Override Collection<String> getAllAssetGroupNames(); @Override Page<AssetGroupView> getAllAssetGroupDetails(final String searchTerm, final int page, final int size); @Override AssetGroupDetails findByGroupName(String groupName); @SuppressWarnings("unchecked") @Override String updateAssetGroupDetails(final CreateUpdateAssetGroupDetails updateAssetGroupDetails, final String userId); @Override String createAssetGroupDetails(final CreateUpdateAssetGroupDetails createAssetGroupDetails, final String userId); @Override UpdateAssetGroupDetails getAssetGroupDetailsByIdAndDataSource(final String assetGroupId, final String dataSource); @Override String deleteAssetGroup(final DeleteAssetGroupRequest assetGroupDetails, final String userId); }
AssetGroupServiceImpl implements AssetGroupService { @Override public String createAssetGroupDetails(final CreateUpdateAssetGroupDetails createAssetGroupDetails, final String userId) throws PacManException { try { Map<String, Object> assetGroupAlias = createAliasForAssetGroup(createAssetGroupDetails); Response response = commonService.invokeAPI("POST", ALIASES, mapper.writeValueAsString(assetGroupAlias)); if(response != null) { if (response.getStatusLine().getStatusCode() == 200) { return processCreateAssetGroupDetails(createAssetGroupDetails, assetGroupAlias, userId); } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } else { throw new PacManException(UNEXPECTED_ERROR_OCCURRED); } } catch (Exception exception) { log.error(UNEXPECTED_ERROR_OCCURRED, exception); throw new PacManException(UNEXPECTED_ERROR_OCCURRED.concat(": ").concat(exception.getMessage())); } }  @Override Collection<String> getAllAssetGroupNames(); @Override Page<AssetGroupView> getAllAssetGroupDetails(final String searchTerm, final int page, final int size); @Override AssetGroupDetails findByGroupName(String groupName); @SuppressWarnings("unchecked") @Override String updateAssetGroupDetails(final CreateUpdateAssetGroupDetails updateAssetGroupDetails, final String userId); @Override String createAssetGroupDetails(final CreateUpdateAssetGroupDetails createAssetGroupDetails, final String userId); @Override UpdateAssetGroupDetails getAssetGroupDetailsByIdAndDataSource(final String assetGroupId, final String dataSource); @Override String deleteAssetGroup(final DeleteAssetGroupRequest assetGroupDetails, final String userId);  }