AssetContentService { public AssetContent createAssetContent(Asset asset, String content) { Branch branch = branchService.getUndeletedOrCreateBranch(asset.getRepository(), null, null); return createAssetContent(asset, content, false, branch); }  AssetContent createAssetContent(Asset asset, String content); AssetContent createAssetContent(Asset asset, String content, boolean extractedContent, Branch branch); AssetContent findOne(Long id);  }
@Test public void createAssetContentAndFind() throws RepositoryNameAlreadyUsedException { Repository repository = repositoryService.createRepository(testIdWatcher.getEntityName("repository")); Asset fortest1 = assetService.createAsset(repository.getId(), "fortest1", false); assertTrue(assetContentRepository.findByAssetRepositoryIdAndBranchName(repository.getId(), null).isEmpty()); AssetContent content1 = assetContentService.createAssetContent(fortest1, "fortest1-content1"); List<AssetContent> assetContents = assetContentRepository.findByAssetRepositoryIdAndBranchName(repository.getId(), null); assertEquals(1L, assetContents.size()); assertEquals("fortest1-content1", assetContents.get(0).getContent()); AssetContent content2 = assetContentService.createAssetContent(fortest1, "fortest1-content2"); assetContents = assetContentRepository.findByAssetRepositoryIdAndBranchName(repository.getId(), null); assertEquals(2L, assetContents.size()); assertEquals("fortest1-content1", assetContents.get(0).getContent()); assertEquals("fortest1-content2", assetContents.get(1).getContent()); AssetContent content2re = assetContentService.createAssetContent(fortest1, "fortest1-content2"); assetContents = assetContentRepository.findByAssetRepositoryIdAndBranchName(repository.getId(), null); assertEquals(3L, assetContents.size()); assertEquals("fortest1-content1", assetContents.get(0).getContent()); assertEquals("fortest1-content2", assetContents.get(1).getContent()); assertEquals("fortest1-content2", assetContents.get(2).getContent()); Asset fortest2 = assetService.createAsset(repository.getId(), "fortest2", false); AssetContent forTest2Content1 = assetContentService.createAssetContent(fortest1, "fortest2-content1"); assetContents = assetContentRepository.findByAssetRepositoryIdAndBranchName(repository.getId(), null); assertEquals(4L, assetContents.size()); assertEquals("fortest1-content1", assetContents.get(0).getContent()); assertEquals("fortest1-content2", assetContents.get(1).getContent()); assertEquals("fortest1-content2", assetContents.get(2).getContent()); assertEquals("fortest2-content1", assetContents.get(3).getContent()); Branch branch1 = branchService.getUndeletedOrCreateBranch(fortest1.getRepository(), "branch1", null); AssetContent forTest2Content1Branch1 = assetContentService.createAssetContent(fortest1, "fortest2-content1-branch1", false, branch1); assetContents = assetContentRepository.findByAssetRepositoryIdAndBranchName(repository.getId(), null); assertEquals(4L, assetContents.size()); assetContents = assetContentRepository.findByAssetRepositoryIdAndBranchName(repository.getId(), "branch1"); assertEquals(1L, assetContents.size()); assertEquals("fortest2-content1-branch1", assetContents.get(0).getContent()); }