Benutzer:JobuBot/JUnit

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen
public class FilmArticleUpdaterTest {

	private Updater pulp, pulpFilm, pulpFiction, leo, leoActor;

	@Before
	public void setUp() {
		pulp = Updater.getFilmArticleUpdater("Pulp");
		pulpFilm = Updater.getFilmArticleUpdater("Pulp (Film)");
		pulpFiction = Updater.getFilmArticleUpdater("Pulp – Fiction");
		leo = Updater.getFilmArticleUpdater("Leonardo DiCaprio");
		leoActor = Updater.getFilmArticleUpdater("Leonardo DiCaprio (Schauspieler)");
	}

	@Test
	public void furtherTemplateFixes() {
		assertEquals("{{Rotten Tomatoes|15_minutes}}", pulp.getUpdatedWikiCode("{{rottentomatoes|1=15_minutes|2=Pulp}}"));
		assertEquals("{{Rotten Tomatoes|15_minutes}}", pulp.getUpdatedWikiCode("{{Rotten Tomatoes|1=15_minutes}}"));
		assertEquals("{{Rotten Tomatoes|1=15/minutes}}", pulp.getUpdatedWikiCode("{{Rotten Tomatoes|1=15/minutes}}"));

		assertEquals("{{OFDb|id}}", pulp.getUpdatedWikiCode("{{ofdb|id}}"));
		assertEquals("{{Film-zeit|id}}", pulp.getUpdatedWikiCode("{{film-zeit|id}}"));
		assertEquals("{{Metacritic|id}}", pulp.getUpdatedWikiCode("{{metacritic|id}}"));
		assertEquals("{{Synchronkartei|film|id}}", pulp.getUpdatedWikiCode("{{synchronkartei|film|id}}"));
		assertEquals("{{Synchronkartei|film|2594|4=2012-07-31}}", pulp.getUpdatedWikiCode("{{Synchronkartei|film|2594|Pulp|2012-07-31}}"));
		assertEquals("{{crew united Titel|1|2}}", pulp.getUpdatedWikiCode("{{Crew united_Titel|1|2}}"));
		assertEquals("{{DNB-Portal|4062683-0}}", pulp.getUpdatedWikiCode("{{DNB-Portal|4062683-0|NAME=Pulp}}"));

		// assertFalse(leo.skip());
		// assertEquals("{{Commonscat}}", leo.getUpdatedWikiCode("{{commonscat|Leonardo DiCaprio}}"));
		// assertEquals("{{Commonscat}}", leo.getUpdatedWikiCode("{{commonscat|2=Leonardo DiCaprio}}"));
		// assertTrue(leo.skip());

		// assertEquals("{{Commonscat|Leonardo DiCaprio}}", leoActor.getUpdatedWikiCode("{{commonscat|Leonardo DiCaprio}}"));
		// assertEquals("{{Commonscat}}", leoActor.getUpdatedWikiCode("{{commonscat|2=Leonardo DiCaprio}}"));

		assertEquals("{{DNB-Portal|135358795|TEXT=Literatur über}}", leo.getUpdatedWikiCode("{{DNB-Portal|135358795|TEXT=Literatur über}}"));
		assertEquals("{{DNB-Portal|135358795|TEXT=Literatur über}}", leo.getUpdatedWikiCode("{{DNB-Portal|135358795|TYP=Literatur über}}"));

		assertEquals("{{DNB-Portal|135358795|NAME=Leonardo DiCaprios|TEXT=Literatur über}}", leo.getUpdatedWikiCode("{{DNB-Portal|135358795|Leonardo DiCaprios|Literatur über}}"));
		assertEquals("{{DNB-Portal|135358795|TEXT=Literatur über}}", leo.getUpdatedWikiCode("{{DNB-Portal|135358795|Leonardo DiCaprio|Literatur über}}"));

		assertEquals("{{LdiF|XXXXXX|titel|zugriff=2015-05-18}}", pulp.getUpdatedWikiCode("{{LdiF|Wert=XXXXXX|Titel=titel|zugriff=2015-05-18}}"));
		assertEquals("{{LdiF|XXXXXX|zugriff=2015-05-18}}", pulp.getUpdatedWikiCode("{{LdiF|Wert=XXXXXX|Titel=Pulp|Download=2015-05-18}}"));
		assertEquals("{{LdiF|XXXXXX|nururl=ja}}", pulp.getUpdatedWikiCode("{{LdiF|Wert=XXXXXX|Titel=Pulp|NurURL=ja}}"));

		assertEquals("{{LdiF|XXXXXX|nururl=ja}}", pulp.getUpdatedWikiCode("{{LdiF\n|Wert=XXXXXX\n|\n\nTitel\n=Pulp\n|NurURL=ja}}"));
	}

	// @Test
	public void actress() {
		assertEquals("Sie ist eine große [[Schauspieler]]in.", leo.getUpdatedWikiCode("Sie ist eine große [[Schauspielerin]]."));
		assertEquals("Sie bekam den [[Schauspielerin]]pokal.", leo.getUpdatedWikiCode("Sie bekam den [[Schauspielerin]]pokal."));
	}

	@Test
	public void imdb() {
		assertEquals("{{IMDb|nm0000138}}", leo.getUpdatedWikiCode("{{IMDb|1=nm0000138}}"));
		assertEquals("{{IMDb|nm0000138}}", leo.getUpdatedWikiCode("{{IMDb| nm0000138}}"));
		assertEquals("{{IMDb|nm0000138}}", leo.getUpdatedWikiCode("{{iMDb| nm0000138}}"));
	}

	@Test
	public void imdbNameAndOthers() {
		assertEquals("{{IMDb|nm0000138}}", leo.getUpdatedWikiCode("{{IMDb Name|0000138}}"));
		assertEquals("{{IMDb|nm0000138}}", leo.getUpdatedWikiCode("{{IMDb name|0000138}}"));
		assertEquals("{{IMDb|nm0000138}}", leo.getUpdatedWikiCode("{{iMDb name|0000138}}"));
		assertEquals("{{IMDb|nm0000138}}", leo.getUpdatedWikiCode("{{IMDb Name|0000138|Leonardo DiCaprio}}"));

		assertEquals("{{IMDb|co0000138}}", leo.getUpdatedWikiCode("{{IMDb Unternehmen|0000138}}"));
		assertEquals("{{IMDb|co0000138|Filmstudio}}", leo.getUpdatedWikiCode("{{IMDb Unternehmen|0000138|Filmstudio}}"));

		assertEquals("{{IMDb|ev0000138}}", leo.getUpdatedWikiCode("{{IMDb Veranstaltung|0000138}}"));
	}

	@Test
	public void imdbTitel() {
		assertEquals("Standard", "{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912}}"));
		assertEquals("Anfang klein", "{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{iMDb Titel|tt0110912}}"));
		assertEquals("Leerzeichen", "{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{ IMDb Titel|tt0110912}}"));
		assertEquals("Unterstrich", "{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb_Titel|tt0110912}}"));
		assertEquals("Alles zusammen", "{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{ iMDb_Titel|tt0110912}}"));

		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912|}}"));
		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Pulp}}"));
		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Pulp }}"));
		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912| Pulp}}"));
		assertEquals("{{IMDb|tt0110912|Fiction}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Fiction}}"));
		assertEquals("{{IMDb|tt0110912|Fiction}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Fiction }}"));

		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|ID=tt0110912}}"));
		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912|NAME=Pulp}}"));
		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|ID=tt0110912|NAME=Pulp}}"));
		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|1=tt0110912|2=Pulp}}"));
		assertEquals("{{IMDb|tt0110912}}", pulp.getUpdatedWikiCode("{{IMDb Titel|1=tt0110912|NAME=Pulp}}"));
		assertEquals("{{IMDb|tt0110912|Pulp Fiction}}", pulp.getUpdatedWikiCode("{{IMDb Titel|ID=tt0110912|NAME=Pulp Fiction}}"));

		assertEquals("{{IMDb|tt0110912}} und {{IMDb|tt0110912|Fiction}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Pulp}} und {{IMDb Titel|tt0110912|Fiction}}"));

		assertEquals("{{IMDb|tt0110912}}", pulpFiction.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Pulp - Fiction}}"));
		assertEquals("{{IMDb|tt0110912|Pulp-Fiction}}", pulpFiction.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Pulp-Fiction}}"));

		assertEquals("{{IMDb|tt0110912}}", pulpFilm.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Pulp}}"));
		assertEquals("{{IMDb|tt0110912|Fiction}}", pulpFilm.getUpdatedWikiCode("{{IMDb Titel|tt0110912|Fiction}}"));

		String[] changeNothing = { "{{-IMDb Titel|tt0110912}}", "{{IMDb-Titel|tt0110912}}", "{{IMDb Titel|nm0110912}}", "{{IMDb Title|tt0110912}}" };
		for (String sourcecode : changeNothing) {
			assertEquals(sourcecode, pulp.getUpdatedWikiCode(sourcecode));
		}

		assertEquals("{{IMDb|tt0110912/episodes}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912/episodes}}"));
		assertEquals("{{IMDb|tt0110912/episodes}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912/episodes|}}"));
		assertEquals("{{IMDb|tt0110912/episodes}}", pulp.getUpdatedWikiCode("{{IMDb Titel|tt0110912/episodes|Pulp}}"));
	}

}