@Test public void testGetAsset() { final Asset expectedAsset = getAsset(); final List<Asset> assets = new ArrayList<>(); assets.add(expectedAsset); when(assetRepository.findForCriteria(any(AssetCriteria.class))).thenReturn(assets); final Asset actualAsset = assetService.getAsset("ap.kurnool", Long.valueOf("552"), new RequestInfo()); assertEquals(expectedAsset, actualAsset); }
public Asset getAsset(final String tenantId, final Long assetId, final RequestInfo requestInfo) { final List<Long> assetIds = new ArrayList<>(); assetIds.add(assetId); final AssetCriteria assetCriteria = AssetCriteria.builder().tenantId(tenantId).id(assetIds).build(); final List<Asset> assets = getAssets(assetCriteria, requestInfo); if (assets != null && !assets.isEmpty()) return assets.get(0); else throw new RuntimeException( "There is no asset exists for id ::" + assetId + " for tenant id :: " + tenantId); }
AssetService { public Asset getAsset(final String tenantId, final Long assetId, final RequestInfo requestInfo) { final List<Long> assetIds = new ArrayList<>(); assetIds.add(assetId); final AssetCriteria assetCriteria = AssetCriteria.builder().tenantId(tenantId).id(assetIds).build(); final List<Asset> assets = getAssets(assetCriteria, requestInfo); if (assets != null && !assets.isEmpty()) return assets.get(0); else throw new RuntimeException( "There is no asset exists for id ::" + assetId + " for tenant id :: " + tenantId); } }
AssetService { public Asset getAsset(final String tenantId, final Long assetId, final RequestInfo requestInfo) { final List<Long> assetIds = new ArrayList<>(); assetIds.add(assetId); final AssetCriteria assetCriteria = AssetCriteria.builder().tenantId(tenantId).id(assetIds).build(); final List<Asset> assets = getAssets(assetCriteria, requestInfo); if (assets != null && !assets.isEmpty()) return assets.get(0); else throw new RuntimeException( "There is no asset exists for id ::" + assetId + " for tenant id :: " + tenantId); }  }
AssetService { public Asset getAsset(final String tenantId, final Long assetId, final RequestInfo requestInfo) { final List<Long> assetIds = new ArrayList<>(); assetIds.add(assetId); final AssetCriteria assetCriteria = AssetCriteria.builder().tenantId(tenantId).id(assetIds).build(); final List<Asset> assets = getAssets(assetCriteria, requestInfo); if (assets != null && !assets.isEmpty()) return assets.get(0); else throw new RuntimeException( "There is no asset exists for id ::" + assetId + " for tenant id :: " + tenantId); }  List<Asset> getAssets(final AssetCriteria searchAsset, final RequestInfo requestInfo); Asset create(final AssetRequest assetRequest); Asset createAsset(final AssetRequest assetRequest); Asset update(final AssetRequest assetRequest); Asset updateAsset(final AssetRequest assetRequest); Asset getAsset(final String tenantId, final Long assetId, final RequestInfo requestInfo); Map<String, Object> getPaginatedAssets(AssetCriteria assetCriteria, RequestInfo requestInfo); }
AssetService { public Asset getAsset(final String tenantId, final Long assetId, final RequestInfo requestInfo) { final List<Long> assetIds = new ArrayList<>(); assetIds.add(assetId); final AssetCriteria assetCriteria = AssetCriteria.builder().tenantId(tenantId).id(assetIds).build(); final List<Asset> assets = getAssets(assetCriteria, requestInfo); if (assets != null && !assets.isEmpty()) return assets.get(0); else throw new RuntimeException( "There is no asset exists for id ::" + assetId + " for tenant id :: " + tenantId); }  List<Asset> getAssets(final AssetCriteria searchAsset, final RequestInfo requestInfo); Asset create(final AssetRequest assetRequest); Asset createAsset(final AssetRequest assetRequest); Asset update(final AssetRequest assetRequest); Asset updateAsset(final AssetRequest assetRequest); Asset getAsset(final String tenantId, final Long assetId, final RequestInfo requestInfo); Map<String, Object> getPaginatedAssets(AssetCriteria assetCriteria, RequestInfo requestInfo);  }