package com.nrusev;

import com.nrusev.domain.Team;
import com.nrusev.repository.TeamRepository;
import com.nrusev.service.TeamService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = EasyApplication.class)
@WebAppConfiguration
public class EasyApplicationTests {
	@Autowired
	TeamRepository teamRepository;

	@Autowired
	TeamService teamService;


	@Test
	public void contextLoads() {
	}


	@Test
	public void intTest(){
		System.out.println( 1 << 30);
	}
	@Test
	public void testGetTeam(){
		List<Team> chelsea = teamRepository.findByTitle("Chelsea");
		System.out.println(chelsea.size());
	}

	@Test
	public void testGetClubTeams(){
		System.out.println(teamService.findAllClubTeams().size());
	}

	@Test
	public void testEuropeanTeams(){
//		teamRepository.findByCountryContinentNameAndNationalIsFalseAndClubIsFalse("Europe");
		List<Team> europe = teamRepository.findByContinentName("Europe", false, true);
		System.out.println(europe.size());
	}

	@Test
	public void testToBinary(){
		System.out.println("binary is " + toBinary(529));
		String binary = toBinary(529);
		int gap = 0,maxGapSize = 0;
		boolean isInGap = false;
		for(int i = 0;i<binary.length();i++){
			char c = binary.charAt(i);
			if(c=='1') {
				isInGap = true;
				if(gap > maxGapSize)
					maxGapSize = gap;
				gap = 0;
				continue;
			}
			if(isInGap && c == '0')
				gap++;
		}

		System.out.println("max gap size is "+ maxGapSize);
	}

	public String toBinary(int n){
		if(n==0)
			return "0";
		if(n==1)
			return "1";
		return toBinary(n/2) + n%2;
	}

}

@@ -772,74 +772,8 @@
 %7D%0A%0A%0A
-%09@Test%0A%09public void intTest()%7B%0A%09%09System.out.println( 1 %3C%3C 30);%0A%09%7D%0A
 %09@Te
@@ -803,16 +803,16 @@
 Team()%7B%0A
+
 %09%09List%3CT
@@ -1292,565 +1292,189 @@
 test
-ToBinary()%7B%0A%09%09System.out.println(%22binary is %22 + toBinary(529));%0A%09%09String binary = toBinary(529);%0A%09%09int gap = 0,maxGapSize = 0;%0A%09%09boolean isInGap = false;%0A%09%09for(int i = 0;i%3Cbinary.length();i++)%7B%0A%09%09%09char c = binary.charAt(i);%0A%09%09%09if(c=='1') %7B%0A%09%09%09%09isInGap = true;%0A%09%09%09%09if(gap %3E maxGapSize)%0A%09%09%09%09%09maxGapSize = gap;%0A%09%09%09%09gap = 0;%0A%09%09%09%09continue;%0A%09%09%09%7D%0A%09%09%09if(isInGap && c == '0')%0A%09%09%09%09gap++;%0A%09%09%7D%0A%0A%09%09System.out.println(%22max gap size is %22+ maxGapSize);%0A%09%7D%0A%0A%09public String toBinary(int n)%7B%0A%09%09if(n==0)%0A%09%09%09return %220%22;%0A%09%09if(n==1)%0A%09%09%09return %221%22;%0A%09%09return toBinary(n/2) + n%252
+AllTeams()%7B%0A//%09%09teamRepository.findByCountryContinentNameAndNationalIsFalseAndClubIsFalse(%22Europe%22);%0A%09%09List%3CTeam%3E all = teamRepository.findAll();%0A%09%09System.out.println(all.size())
 ;%0A%09%7D%0A
-%0A
 %7D%0A

remove unused test cases