/*
 * Copyright 2017 EPAM Systems
 *
 *
 * This file is part of EPAM Report Portal.
 * https://github.com/reportportal/commons-dao
 *
 * Report Portal is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Report Portal is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.epam.ta.reportportal.database.dao;

import com.epam.ta.reportportal.BaseDaoTest;
import com.epam.ta.reportportal.database.entity.Project;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author Andrei Varabyeu
 */
public class ProjectRepositoryTest extends BaseDaoTest {

	@Autowired
	private ProjectRepository projectRepository;

	@Test
	public void testAddNewMetadataPostfix() {
		String projectName = "metadata_test";

		Project p = new Project();
		p.setName(projectName);

		projectRepository.save(p);

		projectRepository.addDemoDataPostfix(projectName, "metadataPostfix");

		List<String> postfixes = projectRepository.findOne(projectName).getMetadata().getDemoDataPostfix();
		Assert.assertThat("Exception during saving demo data postfix", postfixes, CoreMatchers.hasItem("metadataPostfix"));
	}

}
@@ -930,16 +930,83 @@
 roject;%0A
+import com.epam.ta.reportportal.database.entity.project.EntryType;%0A
 import o
@@ -1031,16 +1031,16 @@
 tchers;%0A
-
 import o
@@ -1165,16 +1165,43 @@
 il.List;
+%0Aimport java.util.Optional;
 %0A%0A/**%0A *
@@ -1698,16 +1698,16 @@
 tfix();%0A
-
 %09%09Assert
@@ -1820,9 +1820,384 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void testFindPersonalProjectByUserName() %7B%0A%09%09Project project = new Project();%0A%09%09project.getConfiguration().setEntryType(EntryType.PERSONAL);%0A%09%09project.setName(%22default_personal%22);%0A%09%09projectRepository.save(project);%0A%09%09Optional%3CString%3E defaultPersonal = projectRepository.findPersonalProjectName(%22default%22);%0A%09%09Assert.assertTrue(defaultPersonal.isPresent());%0A%09%7D%0A%0A
 %7D

add unit test