Java Code Examples for edu.emory.mathcs.backport.java.util.Arrays#asList()

The following examples show how to use edu.emory.mathcs.backport.java.util.Arrays#asList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DependencyDumper.java    From depends with MIT License 6 votes vote down vote up
private final void outputDeps(String projectName, String outputDir, String[] outputFormat) {
@SuppressWarnings("unchecked")
List<String> formatList = Arrays.asList(outputFormat);
AbstractFormatDependencyDumper[] builders = new AbstractFormatDependencyDumper[] {
 	new DetailTextFormatDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new XmlFormatDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new JsonFormatDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new ExcelXlsFormatDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new ExcelXlsxFormatDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new DotFormatDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new DotFullnameDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new PlantUmlFormatDependencyDumper(dependencyMatrix,projectName,outputDir),
 	new BriefPlantUmlFormatDependencyDumper(dependencyMatrix,projectName,outputDir)
};
for (AbstractFormatDependencyDumper builder:builders) {
	if (formatList.contains(builder.getFormatName())){
		builder.output();
	}
}
  }
 
Example 2
Source File: TemplateCache.java    From Cynthia with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void remove(UUID[] uuids) {
	for (UUID uuid : uuids) {
		EhcacheHandler.getInstance().delete(EhcacheHandler.FOREVER_CACHE,uuid.getValue());
	}

	List<UUID> deleteTempalteList = Arrays.asList(uuids);

	List<Template> allTempaltes = getAll();
	Iterator<Template> it = allTempaltes.iterator();
	while (it.hasNext()) {
		if (deleteTempalteList.contains(it.next().getId())) {
			it.remove();
		}
	}

	setAll(allTempaltes);
}
 
Example 3
Source File: TemplateTypeCache.java    From Cynthia with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public void remove(UUID[] uuids) {
	for (UUID uuid : uuids) {
		EhcacheHandler.getInstance().delete(EhcacheHandler.FOREVER_CACHE,uuid.getValue());
	}
	
	List<UUID> deleteTempalteList = Arrays.asList(uuids);
	
	List<TemplateType> allTemplateTypes = getAll();
	Iterator<TemplateType> it = allTemplateTypes.iterator();
	while (it.hasNext()) {
		if (deleteTempalteList.contains(it.next().getId())) {
			it.remove();
		}
	}
	
	setAll(allTemplateTypes);
}
 
Example 4
Source File: GameManagingUtilsTest.java    From CodeDefenders with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testSmellGood() throws IOException {
    String testCode = "" + "import org.junit.*;" + "\n" + "import static org.junit.Assert.*;" + "\n"
            + "import static org.hamcrest.MatcherAssert.assertThat;" + "\n"
            + "import static org.hamcrest.Matchers.*;" + "\n" + "public class TestLift {" + "\n"
            + "    @Test(timeout = 4000)" + "\n" + "    public void test() throws Throwable {" + "\n"
            + "        Lift l = new Lift(50);" + "\n" + "        assertEquals(50, l.getTopFloor());" + "\n"
            + "    }" + "\n" + "}";

    org.codedefenders.game.Test newTest = createMockedTest(testCode);
    GameClass cut = createMockedCUT();

    // configure the mock
    gameManagingUtils.detectTestSmells(newTest, cut);

    // Verify that the store method was called once and capture the
    // parameter passed to the invocation
    ArgumentCaptor<TestFile> argument = ArgumentCaptor.forClass(TestFile.class);
    Mockito.verify(mockedTestSmellDAO).storeSmell(Mockito.any(), argument.capture());

    // TODO Probably some smart argument matcher might be needed
    // TODO Matching by string is britlle, maybe match by "class/type"?
    Set<String> expectedSmells = new HashSet<>(Arrays.asList(new String[] {}));
    // Collect smells
    Set<String> actualSmells = new HashSet<>();
    for (AbstractSmell smell : argument.getValue().getTestSmells()) {
        if (smell.getHasSmell()) {
            actualSmells.add(smell.getSmellName());
        }
    }

    Assert.assertEquals(expectedSmells, actualSmells);
}
 
Example 5
Source File: GameManagingUtilsTest.java    From CodeDefenders with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testEagerSmellDoesNotTriggerIfProductionsMethodsAreLessThanThreshold() throws IOException {
    // This has 2 production calls instead of 4 {@link
    // TestSmellDetectorProducer.EAGER_TEST_THRESHOLD}
    String testCode = "" + "import org.junit.*;" + "\n" + "import static org.junit.Assert.*;" + "\n"
            + "import static org.hamcrest.MatcherAssert.assertThat;" + "\n"
            + "import static org.hamcrest.Matchers.*;" + "\n" + "public class TestLift {" + "\n"
            + "    @Test(timeout = 4000)" + "\n" + "    public void test() throws Throwable {" + "\n"
            + "        Lift l = new Lift(50);" + "\n"
            // 1 Production Method call
            + "        l.goUp();" + "\n" //
            // 2 Production Method call
            + "        l.goUp();" + "\n" //
            // Calls inside the assertions (or inside other calls?) are not counted
            + "        assertEquals(50, l.getTopFloor());" + "\n" + "    }" + "\n" + "}";

    org.codedefenders.game.Test newTest = createMockedTest(testCode);
    GameClass cut = createMockedCUT();

    // configure the mock
    gameManagingUtils.detectTestSmells(newTest, cut);

    // Verify that the store method was called
    ArgumentCaptor<TestFile> argument = ArgumentCaptor.forClass(TestFile.class);
    Mockito.verify(mockedTestSmellDAO).storeSmell(Mockito.any(), argument.capture());
    // We expect no smells
    Set<String> noSmellsExpected = new HashSet<>(Arrays.asList(new String[] {}));
    // Collect smells
    Set<String> actualSmells = new HashSet<>();
    for (AbstractSmell smell : argument.getValue().getTestSmells()) {
        if (smell.getHasSmell()) {
            actualSmells.add(smell.getSmellName());
        }
    }

    Assert.assertEquals(noSmellsExpected, actualSmells);
}
 
Example 6
Source File: GalleryListParserTest.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
@ParameterizedRobolectricTestRunner.Parameters(name = "{index}-{0}")
public static List data() {
  return Arrays.asList(new Object[][] {
      { E_MINIMAL },
      { E_MINIMAL_PLUS },
      { E_COMPAT },
      { E_EXTENDED },
      { E_THUMBNAIL },
      { EX_MINIMAL },
      { EX_MINIMAL_PLUS },
      { EX_COMPAT },
      { EX_EXTENDED },
      { EX_THUMBNAIL },
  });
}
 
Example 7
Source File: MediaWikiAPIPageExtractor.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
private boolean extractTopicsFromString(String str, TopicMap t){
    
    String[] titles = str.split(",");
    List<String> titleList = Arrays.asList(titles);
    
    for(String title : titleList){
        try {
            parsePage(title,t);
        } catch (Exception e) {
            log(e);
        }
    }
    
    return true;
}
 
Example 8
Source File: PgpPipeTest.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Parameterized.Parameters(name = "{index} - {0} - {1}")
public static Collection<Object[]> data() {
	// List of the parameters for pipes is as follows:
	// action, secretkey, password, publickey, senders, recipients
	return Arrays.asList(new Object[][]{
			{"Sign then Verify", "success",
					new String[]{"sign", sender[2], sender[1], sender[4], sender[0], recipient[0]},
					new String[]{"verify", recipient[2], recipient[1], recipient[4], sender[0], recipient[0]}},
			{"Encrypt then Decrypt", "success",
					new String[]{"encrypt", null, null, recipient[3], null, recipient[0]},
					new String[]{"dEcryPt", recipient[2], recipient[1], null, null, null}},
			{"Sign then Decrypt", "success",
					new String[]{"sign", sender[2], sender[1], sender[4], sender[0], recipient[0]},
					new String[]{"decrypt", recipient[2], recipient[1], null, null, null}},
			{"Verify Someone Signed", "success",
					new String[]{"sign", sender[2], sender[1], sender[4], sender[0], recipient[0]},
					new String[]{"verify", recipient[2], recipient[1], recipient[4], null, recipient[0]}},
			{"Encrypt then Verify", "org.bouncycastle.openpgp.PGPException",
					new String[]{"encrypt", null, null, recipient[3], null, recipient[0]},
					new String[]{"verify", recipient[2], recipient[1], recipient[4], sender[0], recipient[0]}},
			{"Sign wrong params", "nl.nn.adapterframework.configuration.ConfigurationException",
					new String[]{"sign", null, null, recipient[3], null, recipient[0]},
					new String[]{"decrypt", recipient[2], recipient[1], null, null, null}},
			{"Null action", "nl.nn.adapterframework.configuration.ConfigurationException",
					new String[]{null, null, null, recipient[3], null, recipient[0]},
					new String[]{"decrypt", recipient[2], recipient[1], null, null, null}},
			{"Non-existing action", "nl.nn.adapterframework.configuration.ConfigurationException",
					new String[]{"non-existing action", null, null, recipient[3], null, recipient[0]},
					new String[]{"decrypt", recipient[2], recipient[1], null, null, null}},
			{"Wrong password", "org.bouncycastle.openpgp.PGPException",
					new String[]{"encrypt", null, null, recipient[3], null, recipient[0]},
					new String[]{"decrypt", recipient[2], "wrong password :/", null, null, null}},
			{"Decrypt Plaintext", "org.bouncycastle.openpgp.PGPException",
					new String[]{"decrypt", recipient[2], recipient[1], null, null, null},
					new String[]{"decrypt", recipient[2], recipient[1], null, null, null}},
	});
}
 
Example 9
Source File: FuzzyPhoneNumberHelperTest.java    From mollyim-android with GNU General Public License v3.0 4 votes vote down vote up
private static <E> Set<E> setOf(E... values) {
  //noinspection unchecked
  return new HashSet<>(Arrays.asList(values));
}
 
Example 10
Source File: CellerySignedJWTGenerator.java    From cellery-security with Apache License 2.0 4 votes vote down vote up
private List<String> getScopes(TokenValidationContext validationContext) {

        String[] scopes = validationContext.getTokenInfo().getScopes();
        return scopes != null ? Arrays.asList(scopes) : Collections.emptyList();
    }
 
Example 11
Source File: PropertyVersionChangerTests.java    From spring-cloud-release-tools with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private Set<Project> allProjects() {
	return new HashSet<>(Arrays.asList(
			new Project[] { project("spring-cloud-aws", "1.2.0.BUILD-SNAPSHOT"),
					project("spring-cloud-sleuth", "1.2.0.BUILD-SNAPSHOT") }));
}
 
Example 12
Source File: GameManagingUtilsTest.java    From CodeDefenders with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Test
public void testEagerSmellTriggerIfProductionsMethodsAreEqualThanThreshold() throws IOException {
    // This has 3 production calls instead of 4 {@link
    // TestSmellDetectorProducer.EAGER_TEST_THRESHOLD}
    String testCode = "" + "import org.junit.*;" + "\n" + "import static org.junit.Assert.*;" + "\n"
            + "import static org.hamcrest.MatcherAssert.assertThat;" + "\n"
            + "import static org.hamcrest.Matchers.*;" + "\n" + "public class TestLift {" + "\n"
            + "    @Test(timeout = 4000)" + "\n" + "    public void test() throws Throwable {" + "\n"
            + "        Lift l = new Lift(50);" + "\n"
            // 1 Production Method call
            + "        l.goUp();" + "\n" //
            // 2 Production Method call
            + "        l.goDown();" + "\n" //
            // 3 Production Method call
            + "        l.getTopFloor();" + "\n" //
            // 4 Production Method call
            + "        l.goUp();" + "\n" //
            + "        assertEquals(50, l.getTopFloor());" + "\n" + "    }" + "\n" + "}";

    org.codedefenders.game.Test newTest = createMockedTest(testCode);
    GameClass cut = createMockedCUT();

    // configure the mock
    gameManagingUtils.detectTestSmells(newTest, cut);

    // Verify that the store method was called
    ArgumentCaptor<TestFile> argument = ArgumentCaptor.forClass(TestFile.class);
    Mockito.verify(mockedTestSmellDAO).storeSmell(Mockito.any(), argument.capture());
    // TODO Probably some smart argument matcher might be needed
    // TODO Matching by string is britlle, maybe match by "class/type"?
    Set<String> expectedSmells = new HashSet<>(Arrays.asList(new String[] { "Eager Test" }));
    // Collect smells
    Set<String> actualSmells = new HashSet<>();
    for (AbstractSmell smell : argument.getValue().getTestSmells()) {
        if (smell.getHasSmell()) {
            actualSmells.add(smell.getSmellName());
        }
    }

    Assert.assertEquals(expectedSmells, actualSmells);
}