### Question:
AssetGroupTargetDetailsServiceImpl implements AssetGroupTargetDetailsService, Constants { @Override public List<TargetTypeRuleViewDetails> getTargetTypesByAssetGroupIdAndTargetTypeNotIn(String assetGroupName, Set<String> targetTypeNames) throws PacManException { AssetGroupDetails assetGroupDetails = assetGroupService.findByGroupName(assetGroupName); List<AssetGroupTargetDetails> allAssetGroupTargetDetails = Lists.newArrayList(); if (assetGroupDetails != null) { if(targetTypeNames.isEmpty()) { allAssetGroupTargetDetails = assetGroupTargetDetailsRepository.findByGroupId(assetGroupDetails.getGroupId()); } else { allAssetGroupTargetDetails = assetGroupTargetDetailsRepository.findByGroupIdAndTargetTypeNotIn(assetGroupDetails.getGroupId(), targetTypeNames); } List<TargetTypeRuleViewDetails> allStudentsDetails = allAssetGroupTargetDetails.parallelStream().map(fetchStickyExceptionTargetTypeRuleDetails).collect(Collectors.toList()); return allStudentsDetails; } else { throw new PacManException("Asset Group does not exits"); } }  @Override List<TargetTypeRuleDetails> getTargetTypesByAssetGroupName(String assetGroupName); @Override List<TargetTypeRuleViewDetails> getTargetTypesByAssetGroupIdAndTargetTypeNotIn(String assetGroupName, Set<String> targetTypeNames);  }### Answer:
@Test public void getTargetTypesByAssetGroupIdAndTargetTypeNotInTest() throws PacManException { AssetGroupDetails assetGroupDetails = getAssetGroupDetails(); List<AssetGroupTargetDetails> allAssetGroupTargetDetails = getAllAssetGroupTargetDetails(); when(assetGroupService.findByGroupName("assetGroupName123")).thenReturn(assetGroupDetails); Set<String> targetTypeNames = Sets.newHashSet(); when(assetGroupTargetDetailsRepository.findByGroupIdAndTargetTypeNotIn(assetGroupDetails.getGroupId(), targetTypeNames)).thenReturn(allAssetGroupTargetDetails); assertThat(assetGroupTargetDetailsService.getTargetTypesByAssetGroupIdAndTargetTypeNotIn("assetGroupName123", targetTypeNames).size(), is(1)); }
@Test public void getTargetTypesByAssetGroupIdAndTargetTypeNotInExceptionTest() throws PacManException { AssetGroupDetails assetGroupDetails = getAssetGroupDetails(); List<AssetGroupTargetDetails> allAssetGroupTargetDetails = getAllAssetGroupTargetDetails(); when(assetGroupService.findByGroupName("assetGroupName123")).thenReturn(null); Set<String> targetTypeNames = Sets.newHashSet(); when(assetGroupTargetDetailsRepository.findByGroupIdAndTargetTypeNotIn(assetGroupDetails.getGroupId(), targetTypeNames)).thenReturn(allAssetGroupTargetDetails); assertThatThrownBy(() -> assetGroupTargetDetailsService.getTargetTypesByAssetGroupIdAndTargetTypeNotIn("assetGroupName123", targetTypeNames)).isInstanceOf(PacManException.class); }