@Test public void testScriptFetcher_MockWebServer_CategoryDTOIsPopulated() { remoteAvailableInstallers.populate(); assertEquals("Accessories", observer.getDTO().get(0).getName()); assertEquals(2, observer.getDTO().get(0).getId()); assertEquals(CategoryDTO.CategoryType.INSTALLERS, observer.getDTO().get(0).getType()); }
@Test public void testScriptFetcher_MockWebServer_ApplicationsDTOIsPopulated() { remoteAvailableInstallers.populate(); List<ApplicationDTO> applications = observer.getDTO().get(0).getApplications(); assertEquals("", applications.get(0).getDescription()); assertEquals(373, applications.get(0).getId()); assertEquals( "http://files.playonlinux.com/resources/icones_install/7-Zip", applications.get(0).getIconUrl()); assertEquals(2, applications.get(0).getMiniaturesUrls().size()); assertEquals("7-Zip", applications.get(0).getName()); assertEquals("URL1", applications.get(0).getMiniaturesUrls().get(0)); assertEquals("URL2", applications.get(0).getMiniaturesUrls().get(1)); assertEquals("Amazon Description", applications.get(1).getDescription()); assertEquals(1265, applications.get(1).getId()); assertEquals( "http://files.playonlinux.com/resources/icones_install/Amazon Kindle", applications.get(1).getIconUrl()); assertEquals(0, applications.get(1).getMiniaturesUrls().size()); assertEquals("Amazon Kindle", applications.get(1).getName()); }
@Before public void prepareMockServer() { mockServer .when(request().withMethod("GET").withPath("/categories")) .respond( response() .withStatusCode(200) .withHeaders(new Header("Content-Type", "application/config")) .withBody( "[\n" + " {\n" + " \"applications\": [\n" + " {\n" + " \"id\": 373,\n" + " \"name\": \"7-Zip\",\n" + " \"description\": \"\",\n" + " \"iconUrl\": \"http:\\/\\/files.playonlinux.com\\/resources\\/icones_install\\/7-Zip\",\n" + " \"miniaturesUrls\": [\"URL1\", \"URL2\"],\n" + " \"scripts\": [\n" + " {\n" + " \"scriptName\": \"7-Zip\",\n" + " \"compatibleOperatingSystems\": [\n" + " \"LINUX\",\n" + " \"MACOSX\"\n" + " ],\n" + " \"testingOperatingSystems\": [],\n" + " \"free\": true,\n" + " \"requiresNoCD\": false\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"id\": 1265,\n" + " \"name\": \"Amazon Kindle\",\n" + " \"description\": \"Amazon Description\",\n" + " \"iconUrl\": \"http:\\/\\/files.playonlinux.com\\/resources\\/icones_install\\/Amazon Kindle\",\n" + " \"miniaturesUrls\": [],\n" + " \"scripts\": [\n" + " {\n" + " \"scriptName\": \"Amazon Kindle\",\n" + " \"compatibleOperatingSystems\": [\n" + " \"LINUX\",\n" + " \"MACOSX\"\n" + " ],\n" + " \"testingOperatingSystems\": [],\n" + " \"free\": true,\n" + " \"requiresNoCD\": false\n" + " }\n" + " ]\n" + " }\n" + " ],\n" + " \"id\": 2,\n" + " \"name\": \"Accessories\",\n" + " \"type\": \"INSTALLERS\"\n" + " }\n" + "]\n")); remoteAvailableInstallers = new InstallerSourceWebserviceDefaultImplementation(mockServerURL); observer = new MockObserver(); remoteAvailableInstallers.addObserver(observer); }